# CSS Gets a Class Prefix Selector to Simplify Targeting Multiple Classes

Original title: The Future of CSS: Target Multiple Classes with the Class Prefix Selector

> Hacker News story 49368182 · language: en · submitted 2026-08-19
> Web version: https://zeli.app/story/49368182
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 28 · by [cdrnsf](<https://news.ycombinator.com/user?id=cdrnsf>) · 💬 14
[original](<https://www.bram.us/2026/08/20/the-future-of-css-target-multiple-classes-with-the-class-prefix-selector/>) · [HN discussion](<https://news.ycombinator.com/item?id=49368182>)

## Summary

The CSS Working Group has resolved to add a Class Prefix Selector (`.prefix-*`) to Selectors Level 5, allowing authors to target all classes sharing a prefix without brittle attribute selectors or extra base classes. Proposed by Lea Verou, the selector matches classes like `.btn-primary` and `.btn-secondary` with just `.btn-*`. It currently only supports hyphen separators, and empty or double-hyphen prefixes are excluded. Browser support is nonexistent, but feature detection via `@supports` is possible.

## Key quote

> The `-*` part at the end makes the selector a **Class Prefix Selector** and will try to match any class that begins with that hyphen-separated prefix.

## HN discussion (14 comments)

### [jjcm](<https://news.ycombinator.com/item?id=49368671>)

> In their example, they list btn-* as the selector catch all for .btn-primary|secondary|danger. I can't help but think why not just do, .btn.primary for the class name, and just target .btn with the selector?
>
> Don't get me wrong, I appreciate the convenience of this, but I do worry about selector slowdown with what will effectively turn into a regex at some point. I'm dubious that this is needed.

### [dymk](<https://news.ycombinator.com/item?id=49368867>)

> Personally, I don't think this is a great change to CSS. I prefer being able to grep for identifiers to see where they're used. Now you can't rely on that - maybe a rule is now covered by a prefix selector.

### [yeargun](<https://news.ycombinator.com/item?id=49374949>)

> Hey,
>
> I don't like Browsers to go CISC way. Simpler -> finer ?
>
> Why?
>
> Any feature that we add up indeed cause some extra CPU cycle. I am not a believer that we need an extra regex like this.
>
> Of course, the overhead caused by this is minimal, so is the benefit. Also very tiny percent of web apps will use this anyways.
>
> It could make the shipped css/js to some extent.
>
> Overal I don't like this tradeoff. I dont want web to have more fanout

---

## Cite

- Page: https://zeli.app/story/49368182
- Date: 2026-08-19
- Source: bram.us (https://www.bram.us/2026/08/20/the-future-of-css-target-multiple-classes-with-the-class-prefix-selector/)
- Hacker News: https://news.ycombinator.com/item?id=49368182

## Other languages

- zh: https://zeli.app/zh/story/49368182 · markdown: https://zeli.app/zh/story/49368182.md
- ja: https://zeli.app/ja/story/49368182 · markdown: https://zeli.app/ja/story/49368182.md
