When working with the :disabled
pseudo class, it is important to note that it only functions with input fields such as text inputs, radio buttons, checkboxes, and so on. This pseudo class is triggered when the element has the attribute `disabled="disabled"` applied to it. It's worth mentioning that IE6 does not support this pseudo class, so in order to achieve the desired result, you will need to utilize a separate class.
<input type="text" value="You can't type here" disabled="disabled" class="disabled" />
To style the disabled input above, you can use the following CSS:
input[disabled="disabled"], input.disabled {
/* Add your styles here */
}
This approach ensures that the pseudo class works correctly in modern browsers, while the designated class takes care of compatibility with IE6.
As pointed out by Radeksonic, if you intend to apply disabled styling to other elements like anchor tags, you will have to create a specific class for that purpose, since there is no disabled attribute available for <a>
elements.