Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

:enabled — elements in the enabled state

The :enabled pseudo-class selects elements that support an enabled state and are not disabled. It is not equivalent to lacking a disabled attribute or allowing value editing.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

:enabled

:enabled is a pseudo-class without arguments. In HTML, it matches button, input, select, textarea, optgroup, option, fieldset, and form-associated custom elements that are not actually disabled. Writing input:enabled restricts matching to input elements.

Do not equate :enabled with :not([disabled]): a surrounding fieldset can cause a disabled state even without the element's own disabled attribute. Nor is it equivalent to :not(:disabled), because ordinary elements such as div match neither :enabled nor :disabled.

A field with readonly can still match :enabled: being enabled and being editable are different properties. The CSS properties display and visibility do not change this state. Styling with :enabled does not itself enable a control.

In the example, the selector matches normal and locked. It excludes off, which has the disabled attribute, and nested, which is inside a disabled fieldset. The script prints the identifiers to make local matching checks independent of appearance.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>:enabled example</title>
<style>
  input:enabled { outline: 2px solid green; }
</style>
<form id="demo">
  <label>Normal <input id="normal"></label>
  <label>Read only <input id="locked" readonly value="Fixed"></label>
  <label>Disabled <input id="off" disabled></label>
  <fieldset disabled>
    <legend>Disabled group</legend>
    <label>Nested <input id="nested"></label>
  </fieldset>
</form>
<pre id="result"></pre>
<script>
  const ids = [...document.querySelectorAll('#demo input:enabled')]
    .map(input => input.id);
  document.getElementById('result').textContent = ids.join(', ');
</script>
</html>

Result

normal, locked

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources