You are viewing this site in a simplified layout because your browser does not yet support CSS Subgrid.


How to target HTML elements that have no CSS classes

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[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.