b2KIT

CSS Container Query Builder

Experiment with CSS container queries visually with resizable containers and responsive component code.

Tested tool guide Tested browser tools Checked August 16, 2026

What CSS Container Query Builder does and how it behaves

CSS Container Query Builder lets you establish a query container, resize its preview, and observe a component switching styles at container-width thresholds while producing corresponding CSS. It is intended for component-level responsiveness: a card can change layout when its parent becomes wide enough even though the browser viewport remains unchanged. The usual surprise is that `@container` does not automatically measure the viewport or every ancestor. A size query needs an eligible containment context, commonly created with `container-type: inline-size`, and evaluates the selected query container rather than the component itself.

How the result is produced

1

Resizable query context

The preview separates the component from the viewport by placing it inside a resizable query container. For inline-axis size queries, the relevant CSS declaration is `container-type: inline-size`. Changing the container width lets you inspect the same component on both sides of a breakpoint without treating the entire browser window as the responsive boundary.

2

Breakpoint rules

A threshold becomes an `@container` condition, such as `@container (min-width: 30rem)`, containing the declarations that should apply once the chosen container meets that condition. Base rules remain outside the query. If several thresholds match, ordinary CSS cascade, specificity, and source-order rules still determine which declarations win.

Good uses

  • Testing whether a product card should change from a stacked layout to a horizontal layout when its content region becomes wider.
  • Drafting container-query CSS for a reusable component that may appear in a narrow sidebar or a wide main-content column.
  • Demonstrating why a component can respond differently in two page regions even when both instances share the same viewport width.

Limits and checks

  • The displayed breakpoint is based on the query container, not the viewport. Copying an `@container` block without preserving an eligible container declaration may leave the size query unable to match.
  • An unnamed container query selects the nearest eligible ancestor. Adding another qualifying wrapper during integration can therefore change which dimensions are tested.
  • Matched declarations still participate in the normal cascade. A later rule, a more specific selector, or an `!important` declaration can override the style shown in the builder.

Common questions

Can this builder generate viewport-responsive breakpoints?

No, not as its main purpose. Container queries respond to the dimensions of an eligible ancestor, whereas viewport breakpoints are normally expressed with media queries. Use this builder when a component should adapt to the space allocated by its surrounding layout. Use a media query when the condition genuinely concerns the viewport or another media feature.

Why does the component not change when I resize the browser window?

The queried container may not be changing size, even though the viewport is. Resize the builder's container and check that the relevant ancestor has `container-type: inline-size` or another suitable container type. Also verify that the threshold is crossed and that a nearer eligible ancestor is not being selected unexpectedly.

References and verification

The behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools