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

jarrod Reeves
jarrod Reeves
6,357 Points

Create a new rule that targets the first 4 list items only. Set the font weight to bold.

li:nth-child(n+4){  
font-weight: bold; }

I am getting an error message.

Thanks

3 Answers

Colin Bell
Colin Bell
29,679 Points

Here is another good resource to look at regarding nth-child. nthmaster

James Barnett
James Barnett
39,199 Points

I always look there when I can't remember how to do something like ranges using nth-child.

James Barnett
James Barnett
39,199 Points

I always use that to work out an nth-child before using it in my CSS.

Hugo Paz
Hugo Paz
15,622 Points

What you are doing is not correct. That rule selects the 4, 5, 6...

What you need is li:nth-child(-n+4)