Glossary

CSS Specificity

Specificity is the algorithm by which the browser decides which CSS rule "wins" when there is a conflict. Higher specificity = the rule is applied.

Specificity score

Three groups: (A, B, C)

Examples

#nav .item a:hover  → (0,1,2)  /* ID + class + pseudo-class */
.btn.btn-primary    → (0,0,2)
button              → (0,0,1)
/* The first rule wins */

!important

!important overrides any specificity. Avoid it — makes CSS unpredictable. Only justified for utilities (.hidden { display: none !important; }).

Order when specificity is equal

The rule declared later in the CSS wins.