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 How to Make a Website Responsive Web Design and Testing Refactor the Layout

Nico Dyll
Nico Dyll
2,472 Points

Why is this code: #gallery li:nth child(4n){ clear: left; } not the correct answer for the challenge

I'm not sure why this isn't getting the correct answer on the code challenge.

Jeremy Hogan
Jeremy Hogan
15,451 Points

That's the correct code (except there should be a dash between nth and child). However, when I put that myself in the code challenge, it didn't validate. It took me a moment to notice that the brackets were messed up by their code editor. It usually automatically adds a closing bracket when you open one, but that doesn't happen within media queries, so you were probably missing some closing brackets.

It should look like this when you're done.

@media screen and (min-width: 480px) {
#gallery li {
width:28.3333%;
} /* close it */
  #gallery li:nth-child(4n) {
    clear:left;
  } /* close it */

} /* close the media query */

2 Answers

Jeremy Hogan
Jeremy Hogan
15,451 Points

(copying from comment to answer. Thanks, Jeff) That's the correct code (except there should be a dash between nth and child). However, when I put that myself in the code challenge, it didn't validate. It took me a moment to notice that the brackets were messed up by their code editor. It usually automatically adds a closing bracket when you open one, but that doesn't happen within media queries, so you were probably missing some closing brackets.

It should look like this when you're done.

@media screen and (min-width: 480px) {
#gallery li {
width:28.3333%;
} /* close it */
  #gallery li:nth-child(4n) {
    clear:left;
  } /* close it */

} /* close the media query */
Jeff Lemay
Jeff Lemay
14,268 Points

answered in comments