Search code examples
cssdisabled-input

How remove font color in disabled input


http://jsfiddle.net/NUDDv/

HTML:

<div class="red">
    <input type="text" value="text" disabled="disabled">
    <select disabled>
        <option>aaa</option>
        <option>aaa</option>
    </select>
</div>
<div>
    <input type="text" value="text" disabled="disabled">
    <select disabled>
        <option>aaa</option>
        <option>aaa</option>
    </select>
</div>

CSS:

div.red input[type=text],
div.red select{
    color: red;
}
div.red input[type=text][disabled],
div.red select[disabled]{
    color: none;
}

What I can write to css disabled input for remove red color? I cant' set color, because disabled input don't look good. I would like set this in only CSS.


Solution

  • Keep things simple. Use the :not() pseudo-class.

    See DEMO.

    div.red input[type=text]:not([disabled]),
    div.red select:not([disabled]){
        color: red;
    }