Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Pseudo-classes

The :disabled pseudo-class

Reference for the CSS :disabled pseudo-class: style disabled buttons, inputs, selects and fieldsets, how fieldset inheritance works and accessibility tips.

The :disabled pseudo-class matches form controls that cannot be used: they cannot be focused, clicked, edited or submitted. A control is disabled when it has the disabled attribute, or when it sits inside a disabled <fieldset>.

Use it to make the state obvious, for example by dimming a submit button until a form is ready.

CSS
button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

Try it

Disabled controls and a disabled fieldset

Syntax

CSS
:disabled { /* 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
:disabled No arguments. Matches a control with the disabled attribute, or any control that is a descendant of a disabled <fieldset> (except inside that fieldset's first <legend>).

Usage notes

  • Fieldsets save work. Disabling a <fieldset> disables all its controls at once, and they all match :disabled.
  • Links are not form controls. <a> and <div> never match :disabled. For a link that looks disabled, use aria-disabled="true" and style [aria-disabled="true"].
  • Not submitted. Disabled controls are left out of form submission. If the value must still be sent, use readonly (or a hidden input) instead.
  • Not focusable. Keyboard users skip disabled controls, so explain why something is disabled in nearby text. A button that stays focusable with aria-disabled can show a helpful message.
  • Contrast. Disabled text is exempt from contrast rules, but keep it readable anyway.
  • Default styles. Browsers already grey out disabled controls. Override with care so the state stays visible.

Browser support

Supported in every browser.