Post

To target multiple classes with the same prefix, you'd typically have to resort to brittle attribute selectors. To make things easier, CSS is getting a new selector: the “Class Prefix Selector” (`.foo-*`). Check brm.us/class-prefix... to get the details. (Browser Support: None 😛 — just resolved!)

brm.usThe Future of CSS: Target Multiple Classes with the Class Prefix SelectorTo target multiple classes that share the same prefix, you'd typically have to resort to brittle attribute selectors or add extra base classes to your markup. To make things easier, CSS is getting a n...

27 reposts159 likes

This is very cool! In the current spec it has the same specificity as a regular class, has that been discussed/consciously designed? .foo-* is more 'generic' than .foo-bar, so there's an argument to be made it should have a lower specificity.

Seems like a good thing to bring up at the WG for further discussion. Shall I file an issue, or will you file one?

I thought about this but made þͤ editor decision that it wasn't worth trying to slice specificity more finely for it. Just put your wildcard rule first, that's þͤ normal behavior anyway!

One thing I haven't seen yet is that attribute selectors allow you to specify case sensitivity. But I guess `.foo-*` and `.Foo-*` just follow 'regular' class case sensitivity?

* is used in this exact fashion (standing in for something, rather than being a repetition operator) in many contexts: * þͤ existing universal selector * Posix file globs * normal English

Cool, So we can do what we already could, with fewer keystrokes Meanwhile, we still can't select HTMLUnknownElements with CSS We need some ugly JavaScript code to make the distiction between <tagname> I can't become anything else and <tag-name> I can be a defined Custom Element one day!

Indeed, it could mention why `[class|="foo"]` (even if relaxed as suggested) is also not quite the same as `[class^="foo-"], [class*=" foo-"]` or `.foo-*`.

Are you referring to þͤ * at þͤ end? That's just a *component* of þͤ selector; þͤ "class prefix" is þͤ foo- part that matches þͤ beginning of a class.