CSS: enabled Pseudo Class
The CSS: enabled pseudo-class selects and style elements that are enabled.
These elements are usually form elements, such as buttons (<button>), select menus (<select>), input types (<input>), and textareas (<textarea>).
Enabled elements accept clicks, text input, or focus.
Version ¶
HTML Living Standard
HTML5
Selectors Level 4
Syntax¶
:enabled {
css declarations;
}
Example of the: enabled selector:¶
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
input {
border: 1px solid #ccc;
margin-bottom: 10px;
padding: 2px 5px;
}
input[type=text]:enabled {
background: #eee;
}
input[type=text]:disabled {
background: #ccc;
}
</style>
</head>
<body>
<h2>:enabled selector example</h2>
<form action="#">
<label for="name">First name:</label>
<input type="text" value="John" id="name">
<br>
<label for="lastname">Last name:</label>
<input type="text" value="Smith" id="lastname">
<br>
<label for="country">Country:</label>
<input type="text" disabled="disabled" value="10 High Street" id="country">
</form>
</body>
</html>
Example of the :enabled selector with the <option> tag:¶
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
option:enabled {
background: #666;
}
</style>
</head>
<body>
<h2>:enabled selector example</h2>
<select>
<option value="paris">Paris</option>
<option value="london" disabled>London</option>
<option value="moscow">Moscow</option>
<option value="rome" disabled>Rome</option>
<option value="berlin">Berlin</option>
</select>
</body>
</html>
0 Comments
CAN FEEDBACK
Emoji