A heading can sit comfortably in a wide content panel and become oversized when the same component moves into a narrow sidebar. Container query units let a length respond to the component’s available space, rather than only to the browser window.
Identify the reference dimension
MDN’s container query guide defines cqw as one percent of a query container’s width and cqi as one percent of its inline size. In a common horizontal writing mode, that inline dimension is the width; logical dimensions also accommodate other writing modes.
A suitable ancestor must establish the relevant size container, for example with container-type: inline-size. The descendant can then use a value such as padding-inline: clamp(1rem, 3cqi, 2rem). This illustrative rule allows padding to respond while retaining lower and upper bounds.
The nearest box is not automatically the container
The browser needs an eligible query container for the requested axis. MDN notes that when none is available, container query length units fall back to the corresponding small viewport units. A component can therefore look plausible while sizing against an unintended reference.
During inspection, verify which ancestor establishes containment. Then place the same component in a wide panel and a narrow panel within one page. If both sizes respond only when the browser changes, investigate the container setup before adjusting the numbers.
Test content as well as geometry
Try a long heading, a short heading, and increased text size. Check wrapping and spacing at both component widths. A responsive unit can still produce an uncomfortable reading experience if the chosen bounds are too tight or the content cannot wrap.
Keep an ordinary fallback declaration where your supported browser requirements need it, and test those actual browsers. Container units are most useful when they express a component’s relationship to its space clearly. They should make a reusable element easier to place, not turn a simple layout into a collection of unexplained percentages.

