Earlier quoted context omitted.
This is how you can do all of that: class="hover:red" -> .hover\:red:hover { color: red } class="before:red" -> .before\:red::before { color: red } class="medium:red" -> @media (min-width: 500px) { .medium\:red { color: red } The important thing though is it doesn't need to be used for everything. I think it makes a lot of sense for structural stuff. When you dig into like, children of a hovered element I can see it…
How come people who do this only ever use class names? Why not invent your own data attribute like data-hover="red" where you create new namespaces for things like hover, or pseudo classes, why it it always only ever class names?
The classList API makes modifications to the class property very easily.
You'd be essentially limited to one identifier in attribute selectors. You can't really select from multiple identifiers with a data attribute without doing like:
[data-hover*="foo"]
which would search for "foo" anywhere in the attribute, which could mean incorrect substring matches.Chaining attribute selectors would be rough too:
[data-hover*="foo"][data-hover*="bar"] {}
vs .foo.bar {}