CSS :disabled Pseudo-class

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The :disabled pseudo-class matches form controls that are disabled — they cannot be clicked, typed into, or focused.

Set the HTML disabled attribute (or nest the control in a disabled fieldset). Pair with :enabled for the interactive state. Prefer clear muted styles and cursor: not-allowed so the inactive state is obvious.

Baseline · Widely available.

Not deprecated. Core form-state selector. Extremely broad browser support.

CSS Syntax

syntax.css
:disabled { /* declarations */ }

Often typed as input:disabled, button:disabled, or select:disabled.

Selector Forms

PatternMatchesTry it
input:disabledDisabled text fields and other inputsTry it
button:disabledInactive buttonsTry it
:disabled / :enabledOpposite form states side by sideTry it
fieldset[disabled]Descendant controls become disabled tooTry it

How to Use :disabled

Disable in HTML, then style the state in CSS.

  1. Add disabled on the control (or on a wrapping fieldset).
  2. Write :disabled or a typed form like button:disabled.
  3. Use muted colors, lower opacity, and cursor: not-allowed.
  4. Style :enabled when you want a clear active contrast.
PieceRequired?Role
HTML disabledYes*Turns the control inactive (*or inherit from a disabled fieldset)
:disabledYesSelects that inactive state for styling
Element typeOptionalNarrows the rule (input, button, …)
:enabledOptionalStyles the interactive opposite

Live Preview

Toggle the disabled attribute. The input picks up :disabled styles when inactive.

Muted look + not-allowed cursor when the control matches :disabled.

Form control

Matches input:disabled

CSS Examples

Each snippet focuses on :disabled. Use Try It Yourself for a live editor.

Example 1 — Style a Disabled Input

Mute a locked text field so it looks non-editable.

CSS
<style>
  input:disabled {
    background: #e2e8f0;
    color: #64748b;
    cursor: not-allowed;
  }
</style>

<label for="user">Username</label>
<input id="user" type="text" value="locked" disabled>
<input type="text" placeholder="Editable field">
Try It Yourself

How It Works

  1. HTML. The first input has disabled.
  2. Selector. input:disabled matches only that state.
  3. Look. Gray background and not-allowed cursor signal “locked.”
  4. Second field. No disabled, so it stays default.

Example 2 — Style a Disabled Button

Show that a submit action is unavailable.

CSS
<style>
  button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
</style>

<button type="button">Save</button>
<button type="button" disabled>Save (disabled)</button>
Try It Yourself

How It Works

  1. Attribute. disabled blocks clicks and focus.
  2. Rule. button:disabled lowers opacity.
  3. Cursor. not-allowed reinforces the inactive state.
  4. Active button. Untouched by the rule.

Example 3 — Disable a Whole Fieldset

One disabled on fieldset turns descendant controls inactive — they match :disabled.

CSS
<style>
  input:disabled {
    background: #e2e8f0;
    cursor: not-allowed;
  }
</style>

<fieldset disabled>
  <legend>Billing</legend>
  <input type="text" placeholder="Name">
  <input type="text" placeholder="Zip">
</fieldset>
Try It Yourself

How It Works

  1. Fieldset. disabled on the group disables its controls.
  2. Match. Those inputs still match input:disabled.
  3. One switch. Useful for “same as shipping” style forms.
  4. Legend note. Content in legend is not disabled the same way as nested controls.

Edge Cases & Pitfalls

If styles do not apply, check these first.

aria

aria-disabled ≠ :disabled

Only the HTML disabled state matches. Style ARIA-only cases with [aria-disabled="true"].

vs readonly

Disabled vs read-only

Disabled controls skip focus and form submit. Read-only can still focus and often still submit — see :read-only.

div

Not for plain div/span

:disabled targets form controls that support disabled. Custom widgets need classes or ARIA + JS.

a11y

Do not rely on color alone

Combine muted fill with cursor, contrast, and clear labeling so the inactive state is understandable.

fieldset

Disabled fieldset disables children

Descendant controls match :disabled even without their own attribute. Handy for toggling a whole group.

Browser Support

The :disabled pseudo-class is a browser CSS selector. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

:disabled

Supported in all modern browsers (CSS3-era form selectors). Safe for teaching and production.

100% Core support
Google Chrome 1+
Full support
Mozilla Firefox 1+
Full support
Apple Safari 3.1+
Full support
Microsoft Edge 12+
Full support
Opera 9+
Full support
Samsung Internet 1+
Full support
Internet Explorer 9+
Full support
:disabled Universal

Bottom line: No prefixes. No polyfills. It is not a runtime API.

Key Takeaways

  • Role: style form controls that cannot be activated or focused.
  • Trigger: HTML disabled (or a disabled fieldset).
  • Opposite: use :enabled for interactive controls.
  • Tip: aria-disabled alone does not match :disabled.

One line: :disabled styles inactive form controls so users can tell what they cannot use.

Frequently Asked Questions

It matches form controls that are disabled — they cannot be activated, edited, or focused. Browsers usually gray them out by default; you can add your own styles.
Controls that support the HTML disabled attribute: input, button, select, textarea, fieldset, optgroup, and option. A control inside a disabled fieldset also matches.
:disabled matches inactive controls. :enabled matches the same kinds of controls when they are interactive (no disabled state).
No. Only the HTML disabled attribute (or being disabled via a disabled fieldset) triggers :disabled. Style aria-disabled with [aria-disabled="true"] instead.
Yes. It is Baseline Widely available and works in every modern browser. It is a CSS selector, not a Node.js or runtime API.
No. Disabled controls are skipped on submit and are usually removed from the tab order. Use readonly if the value must still submit.

Next: :empty Pseudo-class

Continue through the CSS tutorial reference.

:empty Pseudo-class tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful