Computer >> Computer tutorials >  >> Programming >> CSS

Usage of CSS :focus pseudo-class


You can try to run the following code to implement :focus pseudo-class

Example

<!DOCTYPE html>
<html>
   <head>
      <style>
         input:focus {
            background-color: orange;
         }
      </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>

Output

Usage of CSS :focus pseudo-class