Rendered from container-queries/allowed.md

Container Queries — Allowed

This gauge covers Chapter 25 after Design Tokens. Complete Chapter 11 (Responsive) first — width media queries remain the page-level tool.

Learning goal

Style a component from its container width instead of the viewport, so the same card can look stacked in a narrow sidebar and multi-column in a wide main column without viewport breakpoints guessing the layout.

Inherited tools

Everything allowed through ../design-tokens/allowed.md and ../responsive/allowed.md remains available.

New CSS

Learning rules

  1. Put container-type on the parent whose width should drive the child.
  2. Query that container with @container, not @media, for component variants.
  3. Keep a usable default layout outside the query; enhance when space allows.
  4. Prefer inline-size containment for width-driven UI; full size containment is rarer and can affect height calculation.
  5. Name containers when a page has more than one nested query context.
  6. Do not replace every viewport query — use media queries for page chrome and container queries for reusable cards, asides, and widgets.

Not allowed

Pages

Rules to lean on

Rules on responsive layout (99–110), design tokens, and the container-query rules added beside them in rules.md.