Open In App

CSS :enabled Selector

The :enabled selector is used to set the background color in enabled element in a form. 

Syntax:



:enabled {
  //property
}

Example: 




<!DOCTYPE html>
<html>
  
<head>
    <style>
        input[type=text]:enabled {
            background: limegreen;
        }
          
        input[type=text]:disabled {
            background: silver;
        }
    </style>
</head>
  
<body>
  
    <form action="">
        Name:
        <input type="text" value="Dharamenda">
        <br>
        <!--enabled-->
  
        User ID:
        <input type="text" disabled="disabled" value="@dharam">
        <br>
        <button type="button">Submit</button>
    </form>
  
</body>
  
</html>

Output:  



Supported Browsers:

Article Tags :