Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

2.1.20 [CSS-Level2-2009] Section 6.4.3, Calculating a selector's specificity

V0027:

The specification states:

 A selector's specificity is calculated as follows:
  
 count 1 if the declaration is from is a 'style' attribute rather than a rule with a 
 selector, 0 otherwise (= a) (In HTML, values of an element's "style" attribute are 
 style sheet rules. These rules have no selectors, so a=1, b=0, c=0, and d=0.) 
 count the number of ID attributes in the selector (= b) 
 count the number of other attributes and pseudo-classes in the selector (= c) 
 count the number of element names and pseudo-elements in the selector (= d)

Quirks Mode (All Versions)

The following selectors and selector features are not supported:

  • All attribute selectors

  • Adjacent sibling and sibling combinators

  • The :active, :first-child, :focus, and :lang pseudo-classes

  • The :after, :before, :first-letter, and :first-line pseudo-elements

  • @page :first, @page :left, and @page :right

The rules are not applied and the selector specificity is zero.

IE7 Mode (All Versions)

The specificity of a selector that ends with a pseudo-element is capped at two no matter how many parent elements precede it.

Show:
© 2015 Microsoft