I'm wondering is there any difference between using the :disabled CSS pseudo-class selector and the [disabled] CSS attribute selector (e.g. different browsers support or whatever) to apply styles on a disabled HTML input element or are they totally equivalent?
2 Answers
:disabled is introduced in css3. [disabled] exists from css2.
I would prefer :disabled over [disabled], see this question from: Should I use CSS :disabled pseudo-class or [disabled] attribute selector or is it a matter of opinion?
Comments
The :disabled approach is supported by browsers that support CSS3, while [disabled] is supported by browsers supporting CSS2 onward.
Browser support is very similar for both; the major difference being IE7 backward vs IE9 backward compatibility.
Likewise, the [disabled] approach is supported by native browsers in older mobile OS versions.
For more details, refer to:
:disabledwill work and[disabled]will not.