CSS · Selectors and cascade

Specificity

The weight that decides which rule wins. Inline styles beat selectors; !important beats everything.

Syntax
id > class > type

Example

Try it

Notes

Keep specificity low and flat. :where() resets it to zero.

More in this group

::after ::before ::placeholder ::selection :active :checked :disabled :empty

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course