Components, Naming, and Organization
What this is. A stylesheet that works is not the same as a stylesheet you can maintain. The difference is almost entirely about naming and where things live.
A component is a self-contained piece of interface: a card, a button, a nav bar. Its styles should be grouped together and named after what it is, so you can find them without searching.
A dependable order for a stylesheet. Custom properties and resets first, then base element styles, then layout, then components, then utilities, then media queries. Following the same order every time means you always know roughly where to look, and it works with the cascade rather than against it.
✦ Specificity should stay flat
If your selectors look like .page .content .card .title span, any future override needs to be even more specific, and the ratchet only turns one way. Aim to style components with a single class wherever you can. Flat specificity is what keeps a stylesheet editable.
Mark this lesson complete
Signed in, your progress follows you to every device.