Calculating a selector’s specificity

men

Do you understend specificity?

Yes! ...... meybe?

men
arrow down

1/30

#myId

Don't know how it works?

arrow down

A selector’s specificity is calculated for a given element as follows:

  • Count the number of ID selectors in the selector (= A)
  • Count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= B)
  • Count the number of type selectors and pseudo-elements in the selector (= C)
  • Ignore the universal selector

If the selector is a selector list, this number is calculated for each selector in the list. For a given matching process against the list, the specificity in effect is that of the most specific selector in the list that matches.

Still have questions?

read more here