New HTML and CSS features you should be using in your design system

Declan Chidlow
Written by Declan Chidlow
Sep 29, 2026

The web platform is the foundation for everything we build on the World Wide Web. HTML and CSS are two of the most important parts of that platform, defining structure and style, respectively. Both have gained a steady stream of new features in recent years, many of which are easy to overlook. A lot of these features are particularly valuable when it comes to establishing design systems that are flexible, adaptable, and easier to maintain.

We often rely on complex libraries and frameworks to define our design systems and apply them during development and in production. However, every additional dependency is another thing to manage. A contained system, without the threat of external variance, goes a long way toward ensuring a design system is the asset it should be, rather than the burden it can become. 

The web platform is stable and well established, so we can trust it to work as we need it to and to treat our design systems with grace and poise.

Sibling functions

sibling-index() and sibling-count() are CSS functions that have recently reached support across all three major browsers and which allow us to style elements based on the number of siblings or the position of an item among its siblings. 

There’s a good chance that just hearing that as a possibility conjured up a million and one ideas in your mind about how you could make your design system dynamic and adaptive to how it’s used. A design system is just that — a system. One that might house any variety of content. 

CSS's sibling functions thankfully give us the ability to make our styles more reactive to how they're being used. sibling-index() returns the position of an item relative to adjacent (sibling) items. sibling-count() returns the number of sibling elements an element possesses, including itself.

Take the example below, where there are three lists: one with few items, one with many, and one with an amount in between. We can use sibling-count() to automatically increase the spacing based on the number of list items present:

See the Pen sibling-count() dynamic list spacing by Declan Chidlow (@OuterVale) on CodePen.

This lets us define components that adapt to the application. We can shrink heading sizes if there are many in use, or enforce a consistent progressive disclosure pattern based on the number of children present. That means we can define and apply a design system that naturally adapts to context, something that has traditionally required hard coding, a build-time step, or JavaScript to achieve. Having this functionality natively in CSS is not only simpler, lighter weight, and more resilient, but it can also be more style-aware.

:has

:has is a pseudo-class that has reached Web Platform Baseline and allows us to apply styles to an element based on its parent, or to a parent based on its child. To target a div only if it contains an image, we can write this selector:

div:has(img) {

There are endless possibilities here for implementing a design system that adapts to the content and application. We can use it in a similar way to the above sibling functions by applying styles to a parent based on its children, such as targeting an ordered list only if the fifth child is a list item:

ol:has(> li:nth-child(5))

The limitation of this approach is that we need to handle each number of items independently, unlike sibling-count(), which is dynamic.

But :has is more than just a parent/child selector. It allows full relational selection, meaning you can also use the next-sibling combinator (+) and the subsequent-sibling combinator (~) to target and apply styles to items. 

Like with sibling functions, this provides us with an opportunity to change styles based on context. For example, we can use :has with the next-sibling combinator to modify the position of a badge based on its placement in a card:

See the Pen :has next-sibling combinator demo by Declan Chidlow (@OuterVale) on CodePen.

If it appears directly after the heading, it’s displayed next to the heading; otherwise, it appears on a new line.

@custom-media

The 'source of truth' is a sacred principle in design systems. Ideally, everything is managed with tokens in a central location, and nothing is hard-coded. One place where values have often had to be hard-coded, or required a pre-processor, is media queries.

Whether you’re defining breakpoints for certain display sizes, styling for certain media types, or handling varied user input methods, media queries are indispensable for making a design system adapt to its context. 

Different modalities come with different considerations, and media queries are integral to addressing that. Even beyond hard-coded values violating our love for tokens, they're also rigid and inflexible. Changing a component's breakpoint could break the layout of a screen if you don’t update it everywhere else, too.

Thankfully, @custom-media is bringing an end to that. With @custom-media we can define media queries and reference them like CSS custom properties (commonly referred to as CSS variables). With custom media queries, both can adapt to a single source of truth, keeping them in sync and allowing dynamic adaptation without breakage.

We can define a custom alias for our media query:

@custom-media --medium-screen (500px <= width <= 1000px);

And then use it as we would a normal media query:

@media (--medium-screen) {
/* Styles for screens that are between 500px and 1000px in width. */
}

The custom media query above also shows an example of a range media query, which lets us set upper and lower limits concisely. That’s another relatively new feature that’s valuable for ensuring our systems adapt to the relevant case.

Custom media queries haven't quite been finalized yet, but we can use them via a build step such as PostCSS Custom Media in preparation for when they do get full browser support.

Popovers

The popover attribute is a new but rather well-supported feature that lets us create content that appears on top of other page content. For example, dialogs, popups, and tooltips.

Elements opened as popovers are always placed on the top layer, so they’ll never appear behind another item. This helps avoid the z-index battle that can happen when multiple conflicting components from a design system are used together.

They're easy to style, too. The ::backdrop pseudo-element is placed behind popovers and takes up the whole screen, which gives us opportunities like darkening the background when a popover is open.

The :popover-open pseudo-class lets us target the popover state, so we can tell when it’s open or closed. As popovers are completely native to the web platform, they can also seamlessly inherit all our CSS styles, custom properties, and more.

In their simplest form, all we need to do is give the element we want to turn into a popover an ID and a popover attribute. Then, we give a button a popovertarget attribute that references the popover element's ID, and the popover is ready to trigger when the button is pressed. 

You can see this basic approach here, complete with ::backdrop to darken the area behind the popover when it’s open:

See the Pen Simple Popover Demo by Declan Chidlow (@OuterVale) on CodePen.

@scope

It doesn't matter how great your design system is if the styles designed for one part leak into another and cause problems. 

Encapsulating styles so they don't have unintended consequences has always been part of writing CSS, and it’s a major consideration when implementing design systems where many different parts need to work together in a wide variety of combinations.

A design system goes out the window as soon as its different parts start fighting. You don't want styles defined for a card to start interacting with your carefully designed navigation or vice versa.

Thankfully, the @scope at-rule, which browsers recently gained support for, allows us to encapsulate components without the risk of styles leaking out and causing unintended consequences elsewhere.

You don't have to write complex selectors, which can be hard to overwrite, just for the purpose of scoping. Instead, you can define the upper and lower bounds of the scope. One of the most useful parts of this is commonly called 'donut scope,' where you only apply styles to part of an element without the style continuing all the way down the cascade, like this:

/* Scopes .card but excludes .content inside .card */
@scope (.card) to (.content) {
	img {
		border-radius: 8px;
	}
}

Here are examples of both a basic scope and a donut scope in use:

See the Pen Simple @scope Demos by Declan Chidlow (@OuterVale) on CodePen.

Text box control

Typography is complex, and the web has historically had middling typographic controls. One place where typography on the web has been particularly difficult is spacing around text. You can have great-looking type in your design software, but when porting it to the web, seemingly spurious padding can be added, making things look very mildly misaligned — just enough to throw off a design.

Paired with text-box-edge, the text-box-trim property allows us to control the spacing above and below text, something that has traditionally required hacky solutions involving negative margins or line-height, which often has negative effects on leading. 

text-box-edge specifies the amount of space to trim, while text-box-trim specifies whether to trim the top edge, bottom edge, or both edges. Both properties are Baseline Newly Available and degrade nicely if support is lacking.

You can see the difference these properties make in this demo:

See the Pen text-box-trim Demo by Declan Chidlow (@OuterVale) on CodePen.

Colors

CSS has particularly come a long way with colors in recent years: You can do a lot with variables, color spaces, color mixing, and inline light/dark theming, all of which have found their way into browsers. 

These features allow design systems to be more flexible with color than ever before, and they’re something that I've covered here on the zeroheight blog before.

Bringing modern web features into your design system

HTML, and particularly CSS, have some new tricks up their sleeves that design systems can apply to great effect. 

Sibling functions, :has, @custom-media, popovers, @scope, more text box controls, and greater color features all make the web platform better than it’s ever been, while unlocking many new possibilities and improvements for design systems. 

Browser support isn't yet universal for all of these features, but it’s getting there. Most also degrade gracefully, so the impact when a user's browser doesn't support them is minimal. 

That said, you should still check support before using these features in production. As support continues to improve, they offer a great way to make your design system more flexible, resilient, and responsive without adding unnecessary complexity.

Declan Chidlow
Declan Chidlow
Declan Chidlow is a front-of-the-front-end developer and writer specializing in core web technologies. With a strong focus on accessibility and usability, they craft digital experiences that are inclusive and user-friendly. They're a well-known voice in the web development community, sharing their expertise on front-end practices through their writing.
Try zeroheight
The design systems platform that keeps teams and agents in sync
Start for free
Share this post