CSS :disabled Pseudo-class
Example
Set a lightgray background color for all disabled <input> elements, and a yellow background color for all enabled <input> elements:
input:disabled {
background-color: lightgray;
}
input:enabled {
background-color: yellow;
}
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The :disabled
pseudo-class is used to select
and style any disabled element (mostly used on form elements).
Tip: The
:enabled
pseudo-class is used to select and
style any enabled element (mostly used on form elements).
Version: | CSS3 |
---|
Browser Support
The numbers in the table specifies the first browser version that fully supports the pseudo-class.
Pseudo-class | |||||
---|---|---|---|---|---|
:disabled | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |
CSS Syntax
More Examples
Example
Set a background color for all disabled <option> elements:
option:disabled {
background-color: lighgray;
}
Try it Yourself »
Related Pages
CSS Reference: :enabled