So, Apple has been shipping out Safari 16 (last night it updated on my mac) on both desktop and ios, and Chrome 105 on both desktop and android is supporting container queries. Which means that this long-awaited revolution in how we can build sites is here, now, in the mainstream (at least for users whose devices auto-update, not those stuck in corporate IT hell while their organisations carry on debating whether to go with Mosaic or Spyglass). There is also a slew of other exciting stuff in the new browser updates (including :has(:target) and subgrid).
If you want a glimpse of what container queries will do, take a look at this pen from Ahmad Shadeed, who has also written about the subject.
https://codepen.io/shadeed/pen/ExZEEjZ?editors=0100
If you look at it first in a browser, like Firefox or Opera, which doesn’t yet support this standard, you’ll see that as you drag the card out from the corner it behaves exactly as we’ve come to expect web elements to behave. But look at it in the new Safari or Chrome, and you will see how the card transforms from small image above text to medium image alongside text to full screen banner with text overlay. Of course, we’ve been able to do this for some time with media queries and breakpoints, but only for larger or smaller devices.
The beauty of this new approach is that we can take a component we have created and it will configure itself according to the size of the space we drop it into. (Think of a blog, for instance, where the newest item automatically fills the whole screen width, but then becomes one of a group of medium sized cards when a new item is added, and then eventually gets shunted into a list of small items.) Design systems like the BBC’s and Guardian’s now become possible to us.
The difference between the new browsers and the old also shows that the design will degrade gracefully on older browsers — they may not give the same effect, but they won’t lose or garble anything (and if we use @supports we can create still elegant designs for older browsers).