CSS Selector - CSS :read-only








The :read-only selector selects elements with a "readonly" attribute.

Summary

CSS Version
3

CSS Syntax

:read-only {
   style properties 
}

Browser compatibility

:read-only Yes No Yes Yes Yes




Example

<!DOCTYPE html>
<html>
<head>
<style>
input:-moz-read-only { /* For Firefox */
    background-color: red;
}<!-- www  . j a v  a2  s. c  o  m-->

input:read-only {
    background-color: red;
}
</style>
</head>
<body>

    <p>A normal input element:<br><input value="hello"></p>
    
    <p>A readonly input element:<br><input readonly value="hello"></p>

</body>
</html>

Click to view the demo