The latest CSS developments have brought forth exciting enhancements that empower web developers to create more expressive and flexible designs. Let's delve into some of the most impactful features:
-
Container Queries:
- These recently became stable across all modern browsers.
- With container queries, you can query a parent element's size and style to determine the styles that should be applied to any of its children.
- Unlike media queries, which work based on the viewport, container queries allow precise styling adjustments for individual components within layouts.
- For instance, in an email inbox layout, the Primary Inbox and Favorites sidebar adjust their grid layout and display email timestamps based on available space¹.
-
Style Queries:
- Partially implemented in Chrome 111, style queries enable you to query the style values of a parent container using CSS custom properties.