CSS :read-onlySelectors

Complete CSS Selector Reference Manual

Example

If the input element has the "readonly" attribute set, set the input box style to yellow:

input:read-only
{
background-color: yellow;
}

Try it Yourself »

Definition and use

The :read-only selector is used to select elements that have the "readonly" attribute set.

Form elements can have the "readonly" attribute set to define the 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 that have the "readonly" attribute set.


Browser Support

The numbers in the table indicate the first browser version number that supports the property.

Selectors
:read-only Supported Not supported -moz-  Yes Yes

CSS Syntax

:read-only
{
CSS Declaration;
}


Related Pages

CSS selectors:read-write


Complete CSS Selector Reference Manual

other extensions