Specificity calculation
noun
say it: “spes-ih-FIS-ih-tee kal-kyuh-LAY-shun” /ˌspɛsɪˈfɪsɪti ˌkælkjəˈleɪʃən/
Working out a selector's specificity as three counts, such as (0, 1, 1): ids, then classes, attributes and pseudo-classes, then element names, and comparing two scores from the left.
How is specificity worked out?
Specificity is counted in three columns: ids, then classes/attributes/pseudo-classes, then tag names. Compare left to right; the first bigger number wins.
#nav .item a /* 1 id, 1 class, 1 tag = (1,1,1) */
.nav .item a /* 0 ids, 2 classes, 1 tag = (0,2,1): loses */
In a sentence
- “Doing the specificity calculation by hand, #menu a scored (1, 0, 1) and beat .nav .link at (0, 2, 0).”
Level: Freelancer · More CSS terms at this level
Updated