How CSS Specificity Is Scored
CSS specificity is expressed as three columns, written a-b-c. Column a counts ID selectors, column b counts classes, attribute selectors and pseudo-classes, and column c counts type selectors and pseudo-elements. The browser compares the columns left to right and never sums them into a single number, so a single ID always outranks any number of classes.
- a = ID selectors
- b = classes, attributes, pseudo-classes
- c = types and pseudo-elements
- Columns are compared left-to-right, never summed
