Is there a CSS selector for element without any class? For example in HTML
Section A
With section:not([class])
you select every section without the class attribute. Unfortunately, it won't select those sections with an empty class attribute value. So in addition, we have to exclude these sections:
section:not([class]) { /* every section without class - but won't select Section C */
color: red;
}
section[class=""] { /* selects only Section C */
font-weight: bold;
}
<section>Section A</section>
<section class="special">Section B</section>
<section class="">Section C</section>