What is the CSS Container Query Generator?
Generate @container query CSS for component-level responsive design. Write container queries that respond to parent width, not viewport width.
Everything runs locally in your browser. Adjust the controls above, preview instantly, and copy clean, production-ready CSS — no account, no upload.
Using the CSS Container Query Generator
Everything lives in the panel at the top of this page. There is nothing to install — it all runs right here in your browser.
Set the container
Add container-type: inline-size to the parent wrapper. This establishes it as a container.
Define breakpoints
Enter the container widths at which the child layout should change (e.g., 400px, 600px).
Copy and customise
The output is a skeleton container query structure. Add your layout rules inside each @container block.
What the generated code looks like
Clean, production-ready CSS — no vendor bloat, no unnecessary declarations.
.card-wrapper {
container-type: inline-size;
container-name: card;
}
.card {
padding: 16px;
font-size: 0.875rem;
}
@container card (min-width: 400px) {
.card {
padding: 24px;
font-size: 1rem;
display: grid;
grid-template-columns: auto 1fr;
}
}
@container card (min-width: 600px) {
.card {
padding: 32px;
}
}container-type: inline-size enables width-based container queries on the element. container-name is optional but required to query a specific ancestor when multiple container contexts exist.
Pro tips for better results
Container queries enable truly portable components
A component styled with container queries works in a sidebar, a main content area, and a modal without any class overrides. The component adapts to whatever space it is given.
Combine container and media queries
Use @media for global layout (columns, page structure) and @container for component-level adaptations within those columns. They are complementary, not competing.
Frequently asked questions
From the blog
Read more →CSS clamp() and Fluid Typography: Stop Writing Font-Size Media Queries (2026)
Learn how CSS clamp() creates type that scales smoothly between screen sizes with a single line, the formula behind it, and how to build a fully fluid type scale without media queries.
CSS Grid vs Flexbox: Which Should You Use? (2026)
CSS Grid vs Flexbox, settled. Here's a senior dev's honest breakdown of when to use each, with real code examples, a comparison table, and no hedging.
CSS Animations: A Practical Guide to Keyframes and Transitions (2026)
Learn the difference between transitions and keyframe animations, how to write @keyframes, the properties worth animating for 60fps, and easing that actually looks good.