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 Pseudo-Classes: :nth-child

Maria Sletbakk
Maria Sletbakk
11,116 Points

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

Cant se whats wrong- can you..?

<!DOCTYPE html>
    <title>Structural Pseudo-classes</title>
    <link rel="stylesheet" type="text/css" href="cc1-main-style.css">
    <link rel="stylesheet" type="text/css" href="style.css">
        <li>List item 1</li>
        <li>List item 2</li>
        <li>List item 3</li>
        <li>List item 4</li>
        <li>List item 5</li>
        <li>List item 6</li>
        <li>List item 7</li>
/* Write your CSS below */
li: nth-child (even)
color: white;
  background-color: black;

4 Answers

I think removing the spaces should fix it:


Chris Shaw
Chris Shaw
26,676 Points

Hi Maria,

CSS is strict in the way you need to write pseudo selectors, in your code you have spaces after the colon and after nth-child which can't be there, simply remove them and the challenge will pass.

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

Happy coding!

Maria Sletbakk
Maria Sletbakk
11,116 Points

Thanks, but suddenly it went throw without any changes

Maria, you’ve got some extra spaces in your css that mess things up. Right there in the selector.

So instead of:

li: nth-child (even)

It should read like this:

   color: white;
   background-color: black;