CSS :enabled Selector

Beginner
⏱️ 5 min read
📚 Updated: Jul 2026
🎯 4 Examples
Form States

What You’ll Learn

The :enabled pseudo-class matches form elements that are interactive and not disabled. Use it to give clear visual feedback about which controls users can interact with.

01

Interactive

Can be used.

02

Form controls

input, button.

03

vs :disabled

Opposite state.

04

Scoped

button:enabled.

05

Hover/focus

Combine states.

06

Default state

Most fields.

Introduction

The :enabled selector in CSS is a pseudo-class used to match form elements that are currently enabled and can be interacted with by the user.

It works with controls that support the disabled attribute, such as <input>, <button>, <select>, <textarea>, <fieldset>, and <optgroup>.

Definition and Usage

Append :enabled to a selector with no space before the colon: input:enabled or button:enabled. Styles apply whenever the element does not have the disabled attribute and is not otherwise inactive.

💡
Beginner Tip

Most form fields are enabled by default. Pair :enabled with :disabled to create a clear visual contrast between active and inactive controls in the same form.

📝 Syntax

The syntax for the :enabled pseudo-class is:

syntax.css
element:enabled {
  /* CSS properties */
}

Basic Example

enabled-basic.css
:enabled {
  border: 2px solid #22c55e;
  background-color: #ecfdf5;
}

:disabled {
  border: 2px solid #94a3b8;
  background-color: #f1f5f9;
  cursor: not-allowed;
}
input:enabled button:enabled select:enabled textarea:enabled

Syntax Rules

  • Only form controls that support disabled can match :enabled.
  • Elements without a disabled attribute are enabled by default.
  • Combine with type selectors: input[type="text"]:enabled.
  • Chain with other pseudo-classes: button:enabled:hover.
  • Use alongside :disabled for complete form state styling.

Supported Elements

ElementSupports :enabled
<input>Yes (text, checkbox, radio, etc.)
<button>Yes
<select>Yes
<textarea>Yes
<fieldset>Yes (when not disabled)
<div>, <p>No (no disabled state)

Related Selectors

  • :disabled — matches inactive form controls
  • :focus — matches when an enabled control has keyboard focus
  • :hover — matches on mouse-over (enabled controls only respond to clicks)
  • :read-only / :read-write — text field editability states

⚡ Quick Reference

QuestionAnswer
Selector typePseudo-class
When it appliesForm control is interactive (not disabled)
Default stateMost controls are enabled unless disabled is set
Opposite:disabled
Common patternbutton:enabled { cursor: pointer; }
Browser supportAll modern browsers

When to Use :enabled

:enabled helps users understand which controls are active:

  • Form validation — Style fields that become enabled after a prerequisite is met.
  • Button states — Give enabled submit buttons a strong call-to-action appearance.
  • Contrast with disabled — Green borders for active fields, gray for locked ones.
  • Conditional forms — Highlight inputs that open up when a checkbox is checked.
  • Cursor feedback — Set cursor: pointer on enabled buttons only.

👀 Live Preview

Enabled controls get green styling; disabled controls appear grayed out:

Examples Gallery

Practice :enabled with form styling, scoped button rules, hover combinations, and mixed enabled/disabled forms.

📜 Core Patterns

Style interactive form controls and contrast them with disabled ones.

Example 1 — Enabled vs disabled form controls

Apply green styling to all enabled controls and gray styling to disabled ones in the same form.

enabled-form.html
<style>
  :enabled {
    border: 2px solid #22c55e;
    background-color: #ecfdf5;
  }

  :disabled {
    border: 2px solid #94a3b8;
    background-color: #f1f5f9;
    cursor: not-allowed;
  }
</style>

<form>
  <input type="text" placeholder="Enter your name">
  <input type="text" placeholder="Locked field" disabled>
  <button type="submit">Submit</button>
  <input type="checkbox" id="agree">
  <label for="agree">I agree to the terms</label>
</form>
Try It Yourself

How It Works

Every enabled control in the form gets the green border. The disabled input is skipped by :enabled and styled by :disabled instead.

Example 2 — Style only enabled buttons

Scope the selector to buttons so text inputs keep their own styling.

button-enabled.css
button:enabled {
  background-color: #2563eb;
  color: #fff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 600;
}

button:disabled {
  background-color: #cbd5e1;
  color: #64748b;
  cursor: not-allowed;
}
Try It Yourself

How It Works

button:enabled targets only clickable buttons. Disabled buttons get muted styling and a not-allowed cursor.

📄 Combined States

Chain :enabled with hover and focus for richer interaction feedback.

Example 3 — Enabled button with hover effect

Add a hover state only on enabled buttons — disabled buttons ignore hover styling.

enabled-hover.css
button:enabled {
  background-color: #2563eb;
  color: #fff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

button:enabled:hover {
  background-color: #1d4ed8;
}

button:enabled:focus {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}
Try It Yourself

How It Works

Chaining :enabled:hover ensures hover effects apply only to interactive buttons. Disabled buttons cannot be hovered in a meaningful way.

Example 4 — Enabled select and textarea

Style dropdowns and text areas based on their enabled state alongside text inputs.

enabled-select.css
select:enabled,
textarea:enabled {
  border: 1px solid #22c55e;
  background-color: #fff;
  padding: 0.5rem;
  border-radius: 0.4rem;
}

select:disabled,
textarea:disabled {
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
  color: #94a3b8;
}
Try It Yourself

How It Works

select and textarea support the disabled attribute just like inputs, so :enabled and :disabled work on them too.

⚠️ Common Pitfalls

  • Non-form elements:enabled has no effect on <div>, <span>, or <a> because they lack a disabled state.
  • Redundant styling — If all fields are enabled, styling the base selector may be simpler than adding :enabled.
  • Specificity order — Place :disabled rules after :enabled when both set the same properties.
  • Fieldset inheritance — Disabling a <fieldset> disables all nested controls; they will not match :enabled.
  • Read-only vs disabled — A read-only input is still :enabled; use :read-only for that state.

♿ Accessibility

  • Do not rely on color alone — Pair green/red borders with labels or helper text explaining why a field is disabled.
  • Keep disabled fields in tab order when needed — Or use aria-disabled with careful styling if you need custom behavior.
  • Focus styles — Style :enabled:focus so keyboard users can see which active field is focused.
  • Explain locked fields — Tell users why a control is disabled (e.g., “Complete step 1 first”).

🧠 How :enabled Works

1

Browser checks the control

For each form element, the browser reads whether the disabled attribute is present.

State
2

:enabled matches active controls

Elements without disabled and that accept user input match the pseudo-class.

Match
3

Styles apply

Your CSS gives visual feedback that the control is interactive.

Render
=

Clear interaction cues

Users instantly see which form controls they can use.

🖥 Browser Compatibility

The :enabled pseudo-class is supported in all modern browsers on form controls. It has been part of CSS since Selectors Level 3.

Baseline · Universal support

Form state styling everywhere

:enabled works reliably in Chrome, Firefox, Safari, Edge, and Opera.

99% Universal support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions
Full support
Opera All modern versions
Full support
:enabled pseudo-class 99% supported

Bottom line: :enabled is safe for production form styling alongside :disabled.

🎉 Conclusion

The :enabled pseudo-class is a straightforward way to style interactive form controls. Combined with :disabled, it helps users instantly recognize which fields and buttons they can use.

Scope it to specific elements like button:enabled, chain it with :hover and :focus, and always consider accessibility when communicating form state visually.

💡 Best Practices

✅ Do

  • Pair :enabled with :disabled for contrast
  • Scope to element types: button:enabled
  • Add cursor: pointer on enabled buttons
  • Chain with :hover and :focus
  • Explain why fields are disabled in helper text

❌ Don’t

  • Apply :enabled to non-form elements
  • Rely on color alone for state feedback
  • Confuse read-only with disabled
  • Forget fieldset disables all nested controls
  • Disable submit buttons without explanation

Key Takeaways

Knowledge Unlocked

Five things to remember about :enabled

Use these points when styling interactive form controls.

5
Core concepts
📝 02

Form controls

input, button.

Targets
🚫 03

vs :disabled

Opposite pair.

Pattern
👆 04

+ hover/focus

Chain states.

Combo
🌐 05

99% support

All browsers.

Compat

❓ Frequently Asked Questions

The :enabled pseudo-class matches form elements that are currently interactive — they do not have the disabled attribute and can receive user input.
Form controls that support the disabled attribute: input, button, select, textarea, fieldset, and optgroup. Elements without a disabled state are always considered enabled.
:enabled matches interactive form controls. :disabled matches the opposite — elements with the disabled attribute or that are otherwise inactive.
Often you style the default state directly and use :disabled for inactive fields. :enabled is useful when you want explicit contrast, such as button:enabled { cursor: pointer; } alongside button:disabled.
Yes. All modern browsers support :enabled on form controls. It has been available since CSS3.

Practice in the Live Editor

Open the HTML editor and experiment with :enabled, :disabled, and form control styling.

HTML Editor →

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.

5 people found this page helpful