Open In App
Related Articles

CSS :enabled Selector

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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

Syntax:

:enabled {
  //property
}

Example: 

HTML

<!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:

  • Google Chrome 1.0
  • Edge 12.0
  • Firefox 1.0
  • Safari 3.1
  • Opera 9.0

Last Updated : 07 Jun, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads