Is there a CSS selector for element without any class? For example in HTML
<section>Section A</section>
<section class="special">Section B</section>
<section class="">Section C</section>
I would like to select Section A (or maybe Section A and Section C, it does not matter that much), by saying something like
section:not(.*) { color: gray }
I understand that I could define it to section and reset it back in all particular classes, like in
section { color: gray }
section.special { color: black }
but this is not what I want, because it is not very manageable once the styles get complex and in some cases it is hard to do the "reset" properly (of course not in this simplified example).
.specialas a "reset", you should see it as a "refinement" applied to a subset of yoursectionselection. The solutions given to your question won't give you optimal performance and will make things more complicated. (By the way, your first CSS example looks shorter because you omit :section { color: black; }).section { color: black; }is omitted is because it's not needed in the first place - presumably it's taking on the default already. The second example clearly shows the redundancy of setting a color for all sections and then having to remove it from every possible class that the sections can have. I don't understand why you think the first example would be more complicated. As for performance, between that and maintainability, you only get to pick one.