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

not working code

li:nth-child(3){
    background-color: #FF6347;
};

That code does not work , why?

3 Answers

Jack Choi
Jack Choi
11,420 Points

Do you mind posting your code so we may see what's wrong? Based on the CSS alone it should work. Here's a quick example I drafted: http://jsfiddle.net/wv9fhk8n/

Michael Hulet
Michael Hulet
47,913 Points

Try removing the semicolon after the closing bracket. It should look like this:

li:nth-child(3){
    background-color: #FF6347;
}
Etienne Gevry
Etienne Gevry
9,611 Points

it needs a space between ) and {

Michael Hulet
Michael Hulet
47,913 Points

Actually, that's in no way required. Personally, I like it without a space