The Web: HTML & CSS
🎯 CSS: selectors, cascade and specificity
Advanced selectors, combinators, pseudo-classes and elements, the cascade, inheritance and how specificity is calculated.
What you'll learn
- Select elements with combinators, pseudo-classes (
:hover,:nth-child), pseudo-elements (::before) and attribute selectors - Distinguish how the cascade and inheritance decide which rule and which value applies to each element
- Calculate a selector's specificity to predict which rule wins and avoid overusing
!important
Lessons
Advanced selectorsCombinators, pseudo-classes, pseudo-elements and attribute selectors. The cascade and inheritanceHow the browser decides which rule wins and which properties are inherited. Specificity and !importantHow a selector's weight is calculated and why you should avoid !important.Practice this module in the app
DevPath is a hands-on course: you read the theory here; in the app you put it into practice with exercises that really run, offline.
Start free in the app →