How these pages write CSS
Every example in this section follows the same habits, and the pages explain why as they go:
- Structure first. Good HTML comes first, and the CSS styles that structure: element and structural selectors before presentational classes.
- Nesting mirrors the HTML's own nesting, so a style sheet reads like the document it styles.
- Simple selectors keep specificity low, so rules stay easy to override.
- Modern features: custom properties hold the design's values, and
@layerputs the cascade in a stated order. - Relative units such as
rem,em,chandclamp(), with logical properties in place of left and right. - Progressive enhancement: a sound baseline first, then preference queries, container queries and
@supportson top.
Where older material teaches a pattern that has since been replaced, such as floats for page layout or px everywhere, the pages show it as history and then show the modern way.
The pages
- 01CSS basics
Structure before style, the browser's own style sheet, normal flow, the anatomy of a rule, where styles come from, and what the browser does with CSS it cannot read.
- 02Selectors and specificity
Selectors as a query language over the document tree: types, classes, attributes, combinators, pseudo-classes,
:is(),:where()and:has(), and keeping specificity low. - 03The cascade, inheritance and scope
How the browser settles competing declarations: origin, importance,
@layer, specificity and order, then@scope, nesting and inheritance. - 04Values, units and functions
The type system, relative and absolute units, specified, computed and used values, math functions, and custom properties.
- 05Properties
The anatomy of a property, shorthands and the global keywords, then text, lists and counters, and backgrounds.
- 06The box model and layout
Boxes, logical properties,
display, normal flow and positioning, then flexbox and grid, with live layout demos. - 07Media contexts and responsive design
Fluid design first, then media, container and preference queries,
@supports, print, and defensive design. - 08CSS for people
Accessibility, performance, internationalization and developer experience, and what frameworks do that the platform now does too.