CSS Container Query Builder
Build CSS container queries visually with container type, name, and size conditions. All processing runs client-side.
About This Tool
The CSS Container Query Builder is a free, browser-based tool that
helps you construct CSS container queries without memorizing the
syntax for container-type, container-name, and @container
rules. Instead of consulting the specification, you choose
options from dropdowns and type your values, and the tool
generates ready-to-use CSS instantly.
Container queries let a component respond to the size of its nearest containment context rather than the viewport. This makes components truly reusable: a card component can switch from a stacked layout to a horizontal one depending on how much space its parent provides, regardless of the screen width.
The builder supports three container types: inline-size
(tracks width only, the most common), size (tracks both
width and height), and normal (no containment, used to
opt out). You can name containers to target specific ancestors
and add multiple size conditions (min-width, max-width,
min-height, max-height, orientation, and more)
combined with and or separated into individual @container
rules with or.
All processing happens entirely in your browser. No data is sent to any server and no account is required. Click Copy or press Ctrl+Shift+C to copy the generated CSS to your clipboard.
This tool pairs well with the CSS @media Query Builder for traditional viewport-based responsive design, the CSS Layout Generator for building grid and flexbox layouts, and the Tailwind Config Builder for setting up container query breakpoints in Tailwind CSS v3.2+.
How to Use
- Select a Container Type from the dropdown:
inline-size(width only),size(width + height), ornormal(no containment). - Enter a Container Name (e.g.
card,sidebar) or leave it blank for an unnamed container query. - Click Add Condition to add a size condition such as
min-width: 400pxormax-width: 800px. - Add more conditions as needed. Use the checkbox next to each condition to enable or disable it.
- Choose whether to combine conditions with and (all must match) or or (separate
@containerrules). - Review the generated CSS in the output panel on the right (or below on mobile).
- Click Copy or press Ctrl+Shift+C to copy the CSS to your clipboard. Alternatively, click a Common Preset to load a popular pattern instantly.
Popular Container Query Guides
FAQ
Is my data safe when using this tool?
Yes. All processing runs entirely in your browser using JavaScript. No data is sent to any server. Your container query CSS is generated locally and never transmitted anywhere.
What is the difference between container queries and media queries?
Media queries respond to the viewport (browser window) size. Container queries respond to the size of a specific parent element. This makes container queries ideal for reusable components that might appear in different layout contexts.
What does container-type: inline-size do?
Setting container-type: inline-size establishes an inline-size containment on the element, which means its children can use @container queries based on width. This is the most commonly used container type because most responsive layouts adapt based on available width.
When should I use container-type: size instead of inline-size?
Use container-type: size when you need to query both width and height of the container. This is less common and requires more careful layout management because the browser must be able to determine the element's size without relying on its content.
Do I need to name my containers?
No. If you omit container-name, the @container query will match the nearest ancestor with containment. Named containers are useful when you have nested containers and want to target a specific one.
What browsers support CSS container queries?
CSS container queries are supported in all modern browsers: Chrome 105+, Firefox 110+, Safari 16+, and Edge 105+. They are safe to use in production for most audiences as of 2024.
Can I combine container queries with media queries?
Yes. Container queries and media queries serve different purposes and can be used together. For example, you might use a media query for overall page layout and container queries for individual component responsiveness.
Related Tools
CSS @media Query Builder
Build CSS media queries visually with support for width, height, orientation, and more.
CSS Layout Generator
Visually build Flexbox and CSS Grid layouts with live preview and generated CSS code.
CSS Selector Tester
Test CSS selectors against HTML markup and see matching elements highlighted.
Tailwind Config Builder
Build tailwind.config.js visually with custom colors, spacing, fonts, and breakpoints.
Viewport Size Reference
Browse 60+ device viewport sizes for responsive web design. Compare iPhone, iPad, Android, laptop, desktop, and TV screen dimensions.