Re:CSS Classes Considered Harmful
by msoad on Wednesday July 17, 2024 @06:34AM
(#40984417)
As this article argues, problem with CSS Classes is that a CSS Class can be applied to _any_ element where custom properties will be scoped to the elements that the CSS was meant to be used for.
[ Parent
| on HN ]
Re:CSS Classes Considered Harmful
by Denvercoder9 on Wednesday July 17, 2024 @06:40AM
(#40984451)
Custom properties can be applied to any element as well. You can constrain the effects of either to only the elements they should affect in your CSS rules.
> Custom properties can be applied to any element as well.
Well, no, they can't. That's the point the article is making.
Classes can compose arbitrarily, i.e. class="size-small size-big"
Whereas data-size="small big", while valid syntax, would not be styled by a rule targeting elem[data-size="small"]