:enabled

The :enabled pseudo-class in CSS selects focusable elements that are not disabled, and therefore enabled. It is only associated with form elements (<input>, <select>, <textarea>). Enabled elements includes ones in that you can select, that you can enter data into, or that you can focus on or click.

So when a checkbox is checked, and you are targeting the label immediately after it:

input:enabled + label {
  color: #333;
  font-style: italic;
} 
 

The label text will dark grey and italic if the checkbox is enabled, meaning the user can toggle it on and off.

In theory, :enabled should match an <a>, <area>, or <link> with href attributes, but browsers don't seem to handle that scenario. You can style <button>, <input>, <textarea>, <optgroup>, <option> and <fieldset>s that are not disabled. When <menu> is supported, we should also be able to target <command> and <li>'s that are children of <menu>, if not disabled.

You would also think that elements with contenteditable and tabindex attributes would be selectable with the :enabled pseudoclass. The spec does not state this, nor do browsers support it.

Browser Support

Chrome Safari Firefox Opera IE Android iOS
All 3.1 All 9 9 All All

Comments

  1. User Avatar
    Stephen

    For a site that teaches about CSS and html you have the slowest site that I have come across in a long time.
    It is slow to scroll and even slow to enter characters into this comment block.

    I and I am sure others will avoid your site as a result

    Cheers

Submit a Comment

Posting Code

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.

icon-closeicon-emailicon-linkicon-logo-staricon-menuicon-searchicon-staricon-tag