I would like to write a CSS selector rule that selects all elements that don\'t have a certain class. For example, given the following HTML:
:not([class])
Actually, this will select anything that does not have a css class (class="css-selector"
) applied to it.
I made a jsfiddle demo
h2 {color:#fff}
:not([class]) {color:red;background-color:blue}
.fake-class {color:green}
fake-class will be green
empty class SHOULD be white
no class should be red
fake-class2 SHOULD be white
empty class2 SHOULD be white
no class2 SHOULD be red
Is this supported? Yes : Caniuse.com (accessed 02 Jan 2020):
Funny edit, I was Googling for the opposite of :not. CSS negation?
selector[class] /* the oposite of :not[]*/