CSS Container Query Generator

Make components respond to the space they are placed in, not just the viewport.

Use the tool

Why this tool exists

The output declares container-type: inline-size and a container-name, adds base grid styles, fluid type using cqi units, two @container rules at your breakpoints, an example using the range syntax and an @supports fallback to media queries. The explanation covers what the query measures and why a container cannot style itself.

Container queries are supported in all current major browsers. Use media queries for page-level layout and container queries for reusable components.

No data is sent anywhere: the work happens in your browser, so you can use it offline once the page has loaded.

How to use it

  1. Name the container and give its selector.
  2. Set two breakpoints in pixels.
  3. Copy the CSS.
  4. Adapt the example rules to your component.

Frequently asked questions

What is cqi?

A container query unit equal to 1% of the container's inline size.

Why does the container not respond to its own query?

A query applies to descendants of the container, not the container itself.

Media or container queries?

Use container queries for components; media queries for global layout and user preferences.

Is my data sent anywhere?

No. Everything is processed in your browser, and the page makes no network requests with your input.