CSS selectors are how you tell the browser which elements to style. Every layout you have ever admired starts here: pick the right elements, apply the right rules. The good news is that you only need a handful of selectors to handle almost everything.
The basics are the element selector ( p ), the class selector ( .card ), and the ID selector ( #header ). Classes are your everyday workhorse β reusable, combinable, and the right choice for almost all styling. IDs should be rare: they are unique by definition and hard to override later.
p { line-height : 1.6 ; } .card { padding : 16px ; border : 1px solid #ddd ; } #header { background : #111 ; color : #fff ; }
Enter fullscreen mode
Exit fullscreen mode
Beyond the basics, combinators let you target elements by their relationships.β¦