CSS :read-only Selector
Example
Select and style only if the input element is "readonly":
input:-moz-read-only { /* For Firefox */
background-color: yellow;
}
input:read-only
{
background-color: yellow;
}
Try it Yourself »
Definition and Usage
The :read-only selector selects elements which are "readonly".
Form elements with a "readonly" attribute are defined as "readonly".
Note: Currently, in most browsers, the :read-only selector only applies to input and textarea elements, but it should apply to all elements which are "readonly".
Version: | CSS3 |
---|
Browser Support
The :read-only selector is supported in Chrome, Safari and Opera.
Internet Explorer does not support the :read-only selector.
Firefox supports an alternative, the :-moz-read-only selector.
Selector | |||||
---|---|---|---|---|---|
:read-only | Yes | Not supported | -moz- | Yes | Yes |
CSS Syntax
:read-only {
css declarations;
}
Related Pages
CSS Selector :read-write