· Updated
HTML elements without a class attribute or with an empty class attribute can be selected in CSS by using the negation pseudo-class and the attribute selector.
For example, to select paragraphs without classes:
p:not([class]),
p[class=''] {
color: red;
}
The first selector in the group selects all paragraphs without a class attribute. The second selects all paragraphs with an empty class attribute. Paragraphs with classes are not affected and can be styled independently.
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.