Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Selectors Advanced Selectors :not() – The Negation Pseudo-Class

Jason S
Jason S
16,247 Points

When is this useful?

under what circumstances would this be useful in a real world situation?

James MacDonald
James MacDonald
Courses Plus Student 6,268 Points

Hi Jason,

Are you referring to the :not pseudo-class? It's not entirely clear from your question.

-Jamie

Jason S
Jason S
16,247 Points

yeah sorry forgot to specify

1 Answer

Sean May
Sean May
9,145 Points

This post on CSS Tricks shows some usage for the :not() pseudo selector.

For most cases, it's not exactly the best practice, it would be better for you to just select things directly instead of selecting something that doesn't have a certain attribute, but in things like lists where you want to create different styling for alternating rows or you want to have a certain set of rows that have certain styling, you could use :not(), but even there it's usually better to just use a class.