CSS Portal

:enabled CSS Pseudo Class

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
:enabled
CSS Pseudo ClassThis pseudo class is supported by all modern browsers.
Updated 31st December 2025

Description

The :enabled pseudo-class in CSS is used to select and style form elements that are currently interactive, meaning they can receive user input. This typically includes elements such as input, select, textarea, and button when they are not disabled. By targeting only enabled elements, developers can apply specific visual styles or behaviors to inputs that the user can actively engage with, while ignoring elements that are disabled and cannot be interacted with.

One common use of :enabled is to visually differentiate interactive form controls from those that are inactive. For example, a submit button might be styled differently when it is enabled versus when it is disabled, improving the clarity of the user interface. This pseudo-class is often paired with :disabled to create contrasting states for form elements. Unlike :focus, which styles elements based on user interaction, :enabled strictly reflects the current capability of the element to accept input.

An example of using :enabled could be:

<form>
  <input type="text" placeholder="Enter name">
  <input type="text" placeholder="Disabled field" disabled>
  <button type="submit">Submit</button>
</form>
input:enabled {
  border: 2px solid #4CAF50;
  background-color: #f0fff0;
}

button:enabled {
  cursor: pointer;
  background-color: #4CAF50;
  color: white;
}

In this example, the enabled input and button receive distinct styling, while the disabled input remains unaffected. Using :enabled enhances accessibility by making interactive elements more visually apparent and ensures a better user experience in forms where some inputs may be temporarily disabled. Additionally, it can be combined with other selectors or pseudo-classes to implement complex UI behaviors, such as conditionally enabling submit buttons based on form validation.

Syntax

:enabled  {
  /* ... */
}

Example

<form>
<label for="name">Active Input:</label>
<input type="text" id="name" placeholder="You can type here">

<label for="blocked">Disabled Input:</label>
<input type="text" id="blocked" placeholder="Locked" disabled>

<div class="button-group">
<button type="submit">Submit (Enabled)</button>
<button type="button" disabled>Locked Button</button>
</div>
</form>
/* Target only elements that are NOT disabled */
input:enabled {
border: 2px solid #2ecc71;
background-color: #f0fff4;
padding: 8px;
border-radius: 4px;
}

button:enabled {
background-color: #3498db;
color: white;
padding: 10px 20px;
border: none;
cursor: pointer;
transition: 0.3s;
}

/* Hover effect only works on enabled buttons */
button:enabled:hover {
background-color: #2980b9;
}

/* Styling the disabled state for contrast */
:disabled {
background-color: #e0e0e0;
border: 2px solid #bdc3c7;
color: #7f8c8d;
cursor: not-allowed;
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS :enabled pseudo class. Hover over a browser icon to see the version that first introduced support for this CSS pseudo class.

This pseudo class is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee