The :enabled CSS pseudo-class represents any enabled element. An element is enabled if it can be activated (e.g. selected, clicked on or accept text input) or accept focus. The element also has an disabled state, in which it can’t be activated or accept focus.
Examples
The following will make the text color a medium green shade when enabled, and a gray shade when disabled. This allows for feedback to the user of which elements are interactable or not.
1
<formaction="url_of_form">
2
<labelfor="FirstField">First field (enabled):</label> <inputtype="text"id="FirstField"value="Lorem"><br/>
3
<labelfor="SecondField">Second field (disabled):</label> <inputtype="text"id="SecondField"value="Ipsum"disabled="disabled"><br/>
4
<inputtype="submit"value="Submit"/>
5
</form>
1
input:enabled {
2
color: #22AA22;
3
}
4
input:disabled {
5
color: #D9D9D9;
6
}
Note that the color of the text on the button is also green, as the button is enabled too.