Skip to content
Related Articles

Related Articles

CSS | :enabled Selector

Improve Article
Save Article
  • Last Updated : 23 Aug, 2022
Improve Article
Save Article

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
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!