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

HTML How to Make a Website Responsive Web Design and Testing Refactor the Layout

Hi! I'm up to the task: "Inside the media query, clear the left side of every 4th list item" it keeps refusing my answer

I have added the code:

  #gallery li {
    width: 28.3333%;
  }

  #gallery li:nth-child (4n) {
    clear: left;
  }

And I have tried numerous attempts at different variants, it's still not accepting my answer?? On my tutorial though in my workspace, it looks perfect. Please advise if I am doing something incorrect?? I am not very happy it won't accept my answers. :(

3 Answers

Just remove the space between li:nth-child and (4n) and it should work.

James Barnett
James Barnett
39,199 Points

I am not very happy it won't accept my answers

9 times out of 10 someone posts on the forum about a code challenge that will not "accept their answer" the reason is their code isn't correct for a hint on what's wrong in this case check out Christian Andersson's earlier reply.

w3c has it without the "n" after the integer:

p:nth-child(2) { background: #ff0000; }

....or does the "n" mean every fourth child versus simply "the fourth" child???

which one is right?

James Barnett
James Barnett
39,199 Points

The way nth-child works is discussed in a latter video, it's an intermediate CSS concept.

Suffice it to say, they are 2 different things:

  • nth-child(4): Select the 4th element
  • nth-child(4n): Select every 4th element