Lesson 4 of 50
cssThe Cascade & Specificity
12 mins
Course progress8%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 4 of 50
css12 mins
Keep these ideas in mind as you work through the lesson.
When multiple rules match the same element, the cascade decides the winner.
style= attribute) – highest origin level.!important elevates a declaration above its origin level.inline → (1,0,0,0)#id → (0,1,0,0).class, [attr], :pseudo‑class → (0,0,1,0)element, ::pseudo‑element → (0,0,0,1)Specificity calculator tip: You can copy a selector into the Chrome DevTools Styles pane; hovering the selector shows its computed specificity.
/* 0,0,0,1 */ p { color:gray; } /* lowest */
/* 0,0,1,0 */ .note { color:blue; }
/* 0,1,0,0 */ #important { color:red; } /* highest */
/* 1,0,0,0 */ <p style="color:green;"> /* inline */
!important for regular styling – it makes later overrides impossible..card not section > div > .card).box-sizing globally to avoid unexpected width calculations.