Role of CSS :focus Selector

CSSWeb DevelopmentFront End Technology

Use the :focus selector to select the element that has focus. You can try to run the following code to implement the :focus selector

Example

<!DOCTYPE html>
<html>
   <head>
      <style>
         input:focus {
            background-color: green;
         }
      </style>
   </head>
   <body>
      <form action = "">
         Subject <input type = "text" name = "subject"><br>
         Student: <input type = "text" name = "student"><br>
         Age: <input type = "number" name = "age"><br>
         <input type = "submit" value = "Submit">
      </form>
   </body>
</html>
raja
Published on 08-May-2018 10:09:54
Advertisements