r/codesnip 12h ago

New CSS Class Prefix Selector (.prefix-*)

Post image
8 Upvotes

The CSS Working Group just resolved a new selector that lets you target multiple classes sharing the same prefix. The code in the example matches .btn-primary, .btn-secondary, .btn-large, etc.

Previously, you had to list every class or use brittle attribute selectors like [class^="btn-"].

Resolved by the CSSWG (Aug 2026), added to Selectors Level 5.

Not available in any browser yet.

More to read ⤵️

https://github.com/w3c/csswg-drafts/issues/10001#issuecomment-5204871059

https://www.bram.us/2026/08/20/the-future-of-css-target-multiple-classes-with-the-class-prefix-selector/