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 psuedo class (:nth-child selector)

Hello! How come I am getting this wrong? The question is: "Use the :nth-child selector to select the even list items only. Set the color to white and the background color to black.

I have this:

li :nth-child (even) 
{ 
  color: white;
  background-color: black; 
}

Thank you!

6 Answers

Make sure you don't have a space between li and nth-child

li:nth-child(even) {
    color: white;
    background-color: black;
}

There is colon after background color. sorry.

Thank you Sam Lucklore! HA! I need a tutorial just on where to put spaces. LOL!

I feel you on that! I find myself on SelectORacle sometimes still when my mind has blanked and something isn't working. Good luck with the rest.

+1 for the SelectORacle

And for complex n-child selectors there's the visual nth-child calculator

L McLean -

I need a tutorial just on where to put spaces.

The only place you should use a space in a CSS selector is for a descendant selector.

Check out this quick tip on the importance of a space in CSS selectors