Role of CSS : read-only Selector


Use the CSS :read-only selector to select elements that are read-only.

Example

You can try to run the following code to implement the :read-only selector:

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         input:read-only {
            background-color: blue;
            color: white;
         }
      </style>
   </head>
   <body>
      <form>
         Subject: <input type = "text" name = "subject" value = "Maths"><br>
         Student: <input type = "text" name = "student" readonly value = "Amit"><br>
      </form>
   </body>
</html>

Updated on: 01-Jul-2020

75 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements