[CSS Selector] E:disabled
Using selector:disabled, you can apply styles to elements in a disabled state. This is commonly called a "UI state pseudo-class." It does not work in IE8 or earlier. A disabled state refers to an element that has the disabled attribute, which prevents user input in form fields such as buttons and textareas. Note that in XHTML, attribute values cannot be omitted, so you must write disabled="disabled".
Sample Code
<input type="button" value="This is a button." disabled> <!-- Specify the disabled attribute like this. --> <input type="button" value="This is a button." disabled="disabled"> <!-- In XHTML, the attribute value cannot be omitted, so you must write disabled="disabled". -->
input:disabled { color: white; background-color: gray;} /* Sets disabled input elements to white text on a gray background. */
Browser Preview
input:disabled { color: white; background-color: gray;} /* Sets disabled input elements to white text on a gray background. */
<input type="button" value="This button is enabled."> <input type="button" value="This button is disabled." disabled> <input type="textarea" value="This textarea is enabled."> <input type="textarea" value="This textarea is disabled." disabled>
Browser Compatibility
Desktop
2 or earlier ×Supported in all versions
8 ×
7 ×
6 ×
8 or earlier ×Mobile
1 or earlier ×
Android Browser
2+ ○Same support as desktop version
Same support as desktop version
※ Version data based on MDN.
If you find any errors or copyright issues, please contact us.