CSS, how to select elements that do NOT have a class
New Course Coming Soon:
Get Really Good at Git
To select elements in an HTML document that do NOT have a class, you can use this:
:not(.class)
For example:
p:not(.description) {
color: red;
}
→ Get my CSS Handbook
→ Read my CSS Tutorial on
The Valley of Code
Here is how can I help you:
- COURSES where I teach everything I know
- CODING BOOTCAMP cohort course - next edition in 2025
- BOOKS 16 coding ebooks you can download for free on JS Python C PHP and lots more
- Follow me on X