CSS container queries: components that adapt to their parent

9 steps · about 2 h 55 min · Intermediate

  1. A Friendly Introduction to Container Queries (article, Josh W. Comeau, 25 min)

    It starts with why media queries fail for components, then builds your first container query step by step.

  2. CSS container queries (guide, MDN Web Docs, 25 min)

    The official reference guide, which locks in container-type, @container, naming and length units.

  3. A Primer On CSS Container Queries (article, Smashing Magazine, 20 min)

    It adds the name/type shorthand, how nested containers behave, and selector rules for what a query can target.

  4. CSS Container Queries Tutorial for Beginners (tutorial, DEV Community, 20 min)

    You build a working card demo in which two cards adapt to their own containers.

  5. Container Queries — CSS Tutorial (tutorial, codekaksha, 15 min)

    A short exercise with a card that goes side by side once the parent is wide enough, plus a common-mistake warning.

  6. CSS Container Queries (article, CSS-Tricks, 25 min)

    It covers the container length units (cqw, cqi, cqmin and the rest) with examples such as radius that scales with the container.

  7. Container Query Units — CSS Units (reference, cssunits.com, 10 min)

    It explains why cqi is the workhorse unit and why a unit needs a declared container ancestor.

  8. Using container size and style queries (guide, MDN Web Docs, 20 min)

    It takes you from size queries to style() queries on custom properties, the newer part of the feature.

  9. CSS Container Queries Guide (guide, design.dev, 15 min)

    A syntax cheat sheet covering range syntax, not, named containers and @supports fallbacks, for use while you build.