Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Pseudo-classes

The :enabled pseudo-class

Reference for the CSS :enabled pseudo-class: match form controls that can be focused and used, how it pairs with :disabled, plus examples and caveats.

The :enabled pseudo-class matches form controls that can be used: they can be focused, clicked, edited and submitted. It is the exact opposite of :disabled among elements that can be disabled.

It is handy for adding hover or cursor styles only to controls that actually react, so a disabled button does not look clickable.

CSS
button:enabled:hover {
  background: #1d4ed8;
}

Try it

Hover effect only on enabled buttons

Syntax

CSS
:enabled { /* declarations */ }
  • Applies to: <button>, <input>, <select>, <textarea>, <optgroup>, <option>, <fieldset> and form-associated custom elements.
  • Specificity: (0,1,0).
  • Inherited / animatable: not applicable.

Values

Syntax and arguments Description
:enabled No arguments. Matches an element that can be disabled but is not.

Usage notes

  • Only disableable elements. A <div> or <a> is neither :enabled nor :disabled. The pseudo-class does not mean "anything that is not disabled".
  • :enabled vs :not(:disabled). On form controls they match the same elements. :not(:disabled) also matches every other element, which is rarely what you want.
  • Specificity trap. button:enabled is more specific than button, so it can override your base rules. Keep that in mind when you later add .primary styles.
  • Read-only is still enabled. An input with readonly is enabled; use :read-only to tell them apart.
  • Fieldsets. Controls inside a disabled <fieldset> are disabled, so they do not match.

Browser support

Supported in every browser.