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

Fedor Andreev
Fedor Andreev
6,438 Points

This question made no sense at all? Maybe I'm wrong?

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

Ignore the bold, I got that right.

Create a new rule that targets the first 4 list items only.

So target the first 4 list items only. From what I understand, that means, list 1 list 2 list 3 list 4 all have to be colored.

But the answer: 4n+1

Means you start on the first element and skip every 4. It did not select the first 4 lists. I'm so confused..

3 Answers

James Barnett
James Barnett
39,199 Points

Looks like you found a bug as your understanding of nth-child is correct.

  • 4n+1 would select 1, 5, 9 and continue the pattern
  • -n+4 would select just the first 4 (1 to 4)

There's a submit feedback button at the end of every code challenge where you can tell the Treehouse team about any issues you ran into when working on a code challenge, such as the bug you found here.

Adama Sy
Adama Sy
7,076 Points

lol i'm gonna do that soon... As a french guy I do struggle sometimes with the English on this page. Sometimes they don't actually make sens to me, but I always find a way. :)

Hi Fedor,

(-n+4) starts at the fourth item and selects every item before it.

Jeff

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