0Pricing
CSS Academy · Lesson

container-type and container-name

Define query containers using container-type and give them names with container-name.

What are Container Queries?

Container queries allow CSS to apply styles based on the size of a parent container rather than the viewport. This enables truly component-based responsive design where a component adapts to wherever it is placed.

The Problem Container Queries Solve

With media queries, a card component in a 300px sidebar cannot know it is small — it only knows the viewport is wide. Container queries let the component react to its own container's size, not the global viewport.

All lessons in this course

  1. container-type and container-name
  2. @container Rules and Breakpoints
  3. Container Query Units: cqw cqh
  4. Container Queries vs Media Queries
← Back to CSS Academy