Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling of disabled input elements - discrepancy between Chrome and Firefox

I have a disabled input element that I am styling using the following CSS:

input[disabled='disabled'] {
    color: #666;
}

This CSS works as expected in Firefox, but Chrome renders the text color several shades too light. If I set the color all the way to black #000000 Chrome renders it as a dark grey instead of black. The problem here is that the CSS produces the expected result in Firefox, but not in Chrome.

An example in JSFiddle which will showcase the discrepancy: http://jsfiddle.net/2AtGX/

How can I get this disabled input element to look the same in Firefox and Chrome?

like image 659
Richard Keller Avatar asked Dec 07 '11 09:12

Richard Keller


People also ask

How do I change input type Disabled in HTML?

The disabled attribute can be set to keep a user from using the <input> element until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the <input> element usable. Tip: Disabled <input> elements in a form will not be submitted!

How do I change the color of disabled input?

Approach: With adding basic CSS property we are able to change the font-color of a disabled input. The disabled input element is unusable and un-clickable. This is a boolean attribute. Here using the color property of input we can change the font-color of this disabled input element.

What HTML elements can be disabled?

The disabled attribute is supported by <button> , <command> , <fieldset> , <keygen> , <optgroup> , <option> , <select> , <textarea> and <input> . This Boolean disabled attribute indicates that the user cannot interact with the control or its descendant controls.


1 Answers

Please check this link for the answer:

How can I fully override Chromium disabled input field colours?

Short answer: set -webkit-text-fill-color: black

like image 84
Interrobang Avatar answered Oct 04 '22 14:10

Interrobang