Native container queries look increasingly imminent: Google is prototyping a syntax originally proposed by David Baron and refined by Miriam Suzanne, and early work also exists on switch(), which behaves like container queries applied to values. Until that lands, the established shortcut is JavaScript that tracks a container's width and exposes styling hooks — usually classes or data attributes. The Raven technique already produces container-query-like values purely in CSS, but expect this area to settle only over time.
ResizeObserver-based options
Most of the minimal implementations share one mechanism, ResizeObserver, and differ mainly in what they attach to the markup:
- Philip Walton's approach builds the pattern by hand: track sizing, then toggle classes as styling hooks.
- Heydon Pickering's
<watched-box>is a web component wrappingResizeObserver, watching sizing and applying classes. It has also been combined withresizeasaurus. - Scott Jehl's
<c-q>is a web component on the same observer, but emits data attributes rather than classes. - Eric Portis's
conditional-classespairsResizeObserverwith a valid CSS custom property syntax to arrive at applied classes.
EQCSS: the non-minimal route
Tommy Hodgins' EQCSS takes a different tack: it scans your CSS for invented syntax and executes element queries (plus other features) from that. It isn't minimalist, and shipping invalid CSS syntax carries some unease, though the implementation looks robust.



