CSS :read-only selector
Complete CSS Selector Reference Manual
Example
If an input element has the "readonly" attribute set, set its style to yellow:
input:read-only
{
background-color: yellow;
}
Try it »
Definition and usage
:read-only selector is used to select elements that have the "readonly" attribute set.
Form elements can set the "readonly" attribute to define an element as read-only.
Note: Currently, in most browsers, the :read-only selector applies to input and textarea elements, but it also applies to elements with the "readonly" attribute set.
Browser support
The numbers in the table indicate the first browser version that supports this property.
| Selector | |||||
|---|---|---|---|---|---|
| :read-only | Supported | Not supported | -moz- | Yes | Yes |
CSS Syntax
:read-only
{
css declaration
;
}
Related pages
CSS selector :read-write