typestar

Selectors & the box model

26 steps in 7 sets of CSS.

Selectors and the box model, which is to say the two things everything else in CSS depends on. Then the cascade, color and type, boxes, units, and styling text content.

Twenty-six steps, every one of them checked against Chromium's own CSS parser. If a property or value in here were invalid, the test suite would have said so.

Start this tour

Selectors

  • Element selectorsRules keyed to element names, plus the grouping and universal forms.
  • Classes and idsClasses are for styling, ids for anchors and labels — their weights differ.
  • CombinatorsDescendant, child, adjacent and general sibling: four ways to relate elements.
  • Attribute selectorsMatching on an attribute's presence or the shape of its value.
  • Pseudo-classesState selectors: hover, focus, disabled, and the structural ones.
  • Structural selectorsSelecting by position: every other row, the first few, the last one.

The cascade

Color & type

  • ColorHex, rgb, hsl and the modern relative forms, plus transparency.
  • Color in a wider gamutoklch is lightness, chroma and hue, so a palette is one number changing at a time.
  • TypographyFamily, size, weight and the spacing that makes text readable.
  • Styling textAlignment, case, decoration and how long lines are handled.

Boxes

Values & units

Styling content

Encore

  • base_styles.cssA complete base stylesheet: reset, tokens, typography and form defaults.

The other CSS tours