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 →Modern CSS techniques every developer should know
A practical tour of the CSS features that replaced yesterday’s hacks.
From design to code without the friction
How visual generators speed up the build without sacrificing clean output.
Writing CSS that scales with your project
Tokens, naming, and structure that keep large stylesheets maintainable.