css3 - Is there a difference in CSS selectors `:enabled` vs `not(:disabled)` -
is there difference in behaviour or browser support using css3 selectors :enabled or not(:disabled)?
i expect them functionally identical, , both css3 selectors, browser support should identical too.
yes, there difference — :not(:disabled) can match elements neither :enabled nor :disabled. these elements enabled/disabled semantics don't apply, such div, p, ul, etc.
the spec confirms this:
what constitutes enabled state, disabled state, , user interface element language-dependent. in typical document elements neither
:enablednor:disabled.
interestingly, same can't said :checked — there no corresponding :unchecked pseudo-class, despite fact not elements have checked/unchecked semantics either. see answer this question.
if you're qualifying these pseudo-classes type selector (such input, select or textarea) or class selector, don't have worry this. still, makes more sense use :enabled :not(:disabled).
browser support majority of level 3 pseudo-classes indeed identical — there no known browsers support either :enabled or :disabled only. however, according mdn looks opera 9.0 , safari 3.1 don't support :not(), although support :enabled , :disabled, , other features substring-matching attribute selectors , general sibling combinator ~ supported in ie7 issues , little bit better in ie8.
Comments
Post a Comment