Calculating specificity
More specific selector, higher priority.
Each selector type contributes a weight. It is often represented as (a, b, c): a = inline styles and !important, b = IDs, c = classes, attributes and pseudo-classes, d = tags and pseudo-elements. In practice, think of: tag = 1 point, class or attribute = 10 points, ID = 100 points. A selector like `#header .nav a` has more specificity than just `a`.
You can consult the web.dev specificity guide and the MDN reference for detailed tables.
- Tag (p, div): 1 point.
- Class (.class), attribute [href], pseudo-class (:hover): 10 points.
- ID (#id): 100 points.
- Inline style (style="..."): 1000 points.