🖨 Print / Save PDF
← Lesson
BitWith
Bite
Full-Stack · Quick Reference
Lesson 7 — CSS Selectors & Specificity
Cheat Sheet
Full-Stack
In one line:
When multiple CSS rules target the same element, specificity decides which one wins.
Selector Types
1
Element
— p, div, h1 (lowest specificity)
2
Class
— .card (medium specificity)
3
ID
— #header (high specificity)
4
Inline style
— style="..." (higher still)
5
!important
— overrides everything (avoid overusing)
Specificity Order (low → high)
element < .class < #id < inline style < !important
p { color: blue; }
Specificity: 0-0-1
.text { color: red; }
Specificity: 0-1-0
#main { color: green; }
Specificity: 1-0-0