Style every checked <input> element with CSS

CSSWeb DevelopmentFront End Technology

To style every checked <input> element, use the CSS :checked selector. You can try to run the following code to implement the :checked selector −

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         input:checked {
            height: 20px;
            width: 20px;
         }
      </style>
   </head>
   <body>
      <p>Fav sports:</p>
      <form action="">
         <input type = "checkbox" value = "Football">Football<br>
         <input type = "checkbox" value = "Cricket">Cricket<br>
         <input type = "checkbox" checked = "checked" value = "Tennis"> Tennis<br>
         <input type = "checkbox" value = "Badminton">Tennis
      </form>
   </body>
</html>

Output

raja
Published on 08-May-2018 13:00:17
Advertisements