Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,843 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,237 Points

it needs a space between ) and {

Michael Hulet
Michael Hulet
47,843 Points

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