The :disabled pseudo-class matches form elements that cannot be interacted with. Use it to give clear visual feedback when controls are temporarily or permanently unavailable.
01
Inactive
Not clickable.
02
Form controls
input, button.
03
vs :enabled
Opposite state.
04
Scoped
button:disabled.
05
Cursor
not-allowed.
06
A11y
Clear contrast.
Fundamentals
Introduction
The :disabled selector in CSS is used to select form elements that are currently disabled — meaning they cannot be interacted with or modified by the user.
This pseudo-class is particularly useful for providing visual feedback on form controls that are temporarily or permanently unavailable, such as a submit button before form validation passes or a username field locked after registration.
Definition and Usage
Append :disabled to a selector with no space before the colon: :disabled, input:disabled, or button:disabled. Styles apply whenever the element has the HTML disabled attribute and disappear when it is removed.
💡
Beginner Tip
Add the disabled attribute in HTML to lock a control: <button disabled>. CSS :disabled styles it automatically — no JavaScript required for basic cases.
Foundation
📝 Syntax
The syntax for the :disabled pseudo-class is:
syntax.css
:disabled{/* CSS properties */}
Basic Example
disabled-form.css
/* Style for disabled elements */:disabled{background-color:#f1f5f9;border:2px solid #94a3b8;color:#94a3b8;cursor:not-allowed;}/* Style for enabled elements (contrast) */:enabled{background-color:#ecfdf5;border:2px solid #22c55e;}
A dashed border and reduced opacity create a softer “locked” look. Ensure contrast still meets accessibility guidelines — do not rely on opacity alone.
Example 4 — Disabled fieldset
Disable an entire group of form controls by setting disabled on a <fieldset>.
When a fieldset is disabled, all nested form controls become disabled automatically. Style the fieldset container to show the entire section is inactive.
Tips
💬 Usage Tips
Use :disabled alongside :enabled to create distinct styles for both states.
Add the disabled attribute in HTML — CSS will apply automatically without JavaScript.
Combine with element selectors (input:disabled, button:disabled) for precise targeting.
Set cursor: not-allowed on disabled controls for immediate visual feedback.
Toggle the disabled attribute with JavaScript for dynamic form validation.
Watch Out
⚠️ Common Pitfalls
Non-form elements — :disabled does not apply to <div> or <span>. Use a class for custom components.
Subtle styling only — Light gray on white may be hard to see. Ensure enough contrast for all users.
aria-disabled alone — CSS :disabled does not match aria-disabled="true" without the HTML disabled attribute.
Disabled vs read-only — Read-only fields can still be focused; disabled fields cannot.
Excluding from forms — Disabled controls are not submitted with form data.
A11y
♿ Accessibility
Visual contrast — Disabled controls must look clearly different from enabled ones.
Do not rely on color alone — Combine color, opacity, cursor, and labels to indicate state.
Screen readers — The disabled attribute is announced automatically; avoid removing it.
Explain why — Add helper text near disabled fields explaining why they are locked.
Focus behavior — Disabled elements are skipped in tab order, which is correct behavior.
🧠 How :disabled Works
1
Element gets disabled attribute
HTML disabled is added in markup or via JavaScript.
HTML
2
Browser blocks interaction
The control cannot be clicked, typed into, or focused. It is excluded from form submission.
Block
3
:disabled styles apply
Your CSS gray-out, opacity, and cursor rules take effect.
Style
=
🚫
Clear inactive state
Users know which controls they cannot use.
Compatibility
🖥 Browser Compatibility
The :disabled pseudo-class is supported in all modern browsers on form controls.
✓ Baseline · Universal support
Disabled styling everywhere
:disabled works reliably in Chrome, Firefox, Safari, Edge, and Opera.
99%Universal support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll modern versions
Full support
:disabled pseudo-class99% supported
Bottom line::disabled is safe to use on all form controls in every modern browser.
Wrap Up
🎉 Conclusion
The :disabled selector is essential for controlling the appearance of form elements that cannot be interacted with. By applying appropriate styles, you ensure users know which controls are inactive and prevent confusion during form submission.
Pair it with :enabled, use clear visual contrast, and always include the HTML disabled attribute for proper behavior and accessibility.
Use high-contrast gray styling for disabled controls
Set cursor: not-allowed on disabled buttons
Pair with :enabled for clear state contrast
Use the HTML disabled attribute, not just CSS
Explain why a field is disabled with helper text
❌ Don’t
Apply :disabled styling to non-form elements
Rely on subtle color changes alone
Expect :disabled to match aria-disabled alone
Confuse disabled with read-only states
Forget disabled fields are not submitted
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about :disabled
Use these points when styling inactive form controls.
5
Core concepts
🚫01
Inactive
Cannot interact.
Purpose
HTML02
disabled attr
HTML trigger.
Markup
vs03
:enabled
Opposite state.
Pair
👆04
not-allowed
Cursor cue.
UX
🌐05
99% support
All browsers.
Compat
❓ Frequently Asked Questions
The :disabled pseudo-class matches form elements that cannot be interacted with — they have the disabled attribute set or are otherwise inactive, such as a grayed-out submit button.
Form controls that support the disabled attribute: input, button, select, textarea, fieldset, and optgroup. Non-form elements like div and span cannot use :disabled unless given a disabled attribute (which has no effect on them).
:disabled matches inactive form controls. :enabled matches the opposite — controls without the disabled attribute that users can interact with.
No. CSS :disabled only matches elements with the HTML disabled attribute. Elements with only aria-disabled="true" need a class or attribute selector unless they also have the disabled attribute.
Yes. All modern browsers support :disabled on form controls. It has been available since CSS3.