CSE 134B Web Client Languages
  1. Presentation
  2. CSS

Presentation · Layer 2

CSS

CSS is the presentation layer that sits on top of HTML's structure. It is a declarative language with a grammar, a type system and a resolution algorithm, and it is written for a medium where the browser and the reader both have a say in the result. These pages teach it that way, one topic per page.

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 @layer puts the cascade in a stated order.
  • Relative units such as rem, em, ch and clamp(), with logical properties in place of left and right.
  • Progressive enhancement: a sound baseline first, then preference queries, container queries and @supports on 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

  1. 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.

  2. 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.

  3. 03The cascade, inheritance and scope

    How the browser settles competing declarations: origin, importance, @layer, specificity and order, then @scope, nesting and inheritance.

  4. 04Values, units and functions

    The type system, relative and absolute units, specified, computed and used values, math functions, and custom properties.

  5. 05Properties

    The anatomy of a property, shorthands and the global keywords, then text, lists and counters, and backgrounds.

  6. 06The box model and layout

    Boxes, logical properties, display, normal flow and positioning, then flexbox and grid, with live layout demos.

  7. 07Media contexts and responsive design

    Fluid design first, then media, container and preference queries, @supports, print, and defensive design.

  8. 08CSS for people

    Accessibility, performance, internationalization and developer experience, and what frameworks do that the platform now does too.