I would like to create a rule for certain elements which only affects an element if it has none of a list of classes.
My attempt:
div:not(.a, .c) {
color: red;
}
<div class="a">a</div>
<div class="b">b</div>
<div class="c">c</div>
If you run this snippet, it obviously does not work as intended. Seems the selector is invalid and does not affect any div
whatsoever.
Next I tried chaining :not()
which seems very clumsy, but works:
div:not(.a):not(.c) {
color: red;
}
<div class="a">a</div>
<div class="b">b</div>
<div class="c">c</div>
Is this the only way to solve the given problem?