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 Foundations Advanced Selectors Additional Pseudo-Classes

christophe Bonge
christophe Bonge
6,618 Points

Hi, problem with pseudo-class :not

when i type

div:not ([id="s1"]) {
  background-color: tomato;
}  

the concerned elements aren't highlighted.

Guil Hernandez
Guil Hernandez
Treehouse Teacher

Hi christophe Bonge,

Looks like the problem here is the space between not and ([id="s1"]). Like Paul Anderson mentioned, you can also omit the square brackets and attribute.

christophe Bonge
christophe Bonge
6,618 Points

Hi thanks Guil for your answer; I didn't pay attention to this space.

3 Answers

If you're selecting classes or id's via the :not pseudo-class you don't need to put in square brackets. Simple add the . or # before the s1. If you were selecting a type of something within that div you would use square brackets, like such [type="file"]. Hope this helps.

Sue Dough
Sue Dough
35,800 Points

Try this

div:not(#s1) {
  background-color: tomato; 
}
christophe Bonge
christophe Bonge
6,618 Points

Thanks for your answers; actually it works; but i don't understand why in the course Guil shows this pseudo selector with this type of syntax selector:not([id="s1"])