CSS Portal

:disabled 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
:disabled
CSS Pseudo ClassThis pseudo class is supported by all modern browsers.
Updated 31st December 2025

Description

The :disabled pseudo-class in CSS is used to target HTML elements that are in a disabled state, meaning they are not interactive or cannot be modified by the user. Typically, elements like input, button, select, and textarea can be disabled either through the presence of the disabled attribute in HTML or through JavaScript manipulation. Applying styles to these elements with :disabled allows designers to visually indicate to users that the element is inactive or unavailable.

For example, you can change the background color, cursor, or opacity to signify that a form field is disabled:

<form>
  <input type="text" placeholder="Enabled field">
  <input type="text" placeholder="Disabled field" disabled>
  <button>Enabled Button</button>
  <button disabled>Disabled Button</button>
</form>
input:disabled,
button:disabled {
  background-color: #f0f0f0;
  color: #888;
  cursor: not-allowed;
}

In this example, the :disabled pseudo-class targets the inputs and buttons that are disabled, applying a lighter background color, muted text, and a cursor style to visually communicate their inactive state.

The :disabled pseudo-class can also be combined with other pseudo-classes, such as :hover or :focus, to ensure that disabled elements do not respond to user interactions or styling intended for active elements. This makes it particularly useful for creating accessible and user-friendly forms, as it provides clear visual feedback while maintaining semantic meaning for assistive technologies.

Additionally, :disabled respects inheritance and specificity rules like other CSS selectors. If you want to style all disabled elements within a container, you could use a descendant selector:

form input:disabled {
  border-color: #ccc;
}

This approach ensures that your UI communicates effectively which elements are inactive while keeping your code maintainable and semantically correct.

Syntax

:disabled {
  /* ... */
}

Example

 <form class="container">
<h3>Feedback Form</h3>

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

<label for="id-number">Disabled Input:</label>
<input type="text" id="id-number" placeholder="This is locked..." disabled>

<div class="button-group">
<button type="submit">Submit Changes</button>
<button type="button" disabled>Cancel (Locked)</button>
</div>
</form>
/* Styling for all inputs and buttons */
input, button {
padding: 10px;
margin: 10px 0;
border-radius: 4px;
border: 1px solid #ccc;
display: block;
}

/* Style for the active button */
button {
background-color: #007bff;
color: white;
cursor: pointer;
}

/* THE :DISABLED PSEUDO-CLASS
This targets any element with the 'disabled' attribute
*/
input:disabled {
background-color: #f5f5f5;
color: #a1a1a1;
border-color: #ddd;
cursor: not-allowed; /* Shows a 'circle-slash' icon on hover */
}

button:disabled {
background-color: #cccccc;
color: #666666;
border: 1px solid #999999;
cursor: not-allowed;
opacity: 0.7;
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS :disabled 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