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

Onaje Baxley
Onaje Baxley
8,302 Points

Inside the media query, clear the left side of every 4th list item in the gallery.

I'm not sure why I can't pass this challenge. I've tried both the nth-child() and nth-of-type() selectors and given them arguments including 4, 4n, 4n+0, and 0n+4, but it seems as if i've hit a brick wall. It the error log is asking me if I made sure I cleared the left side of every 4th list item and I'm 99% sure that clear: left does just that. And yes my exact selectors were inside the same media query as challenge 1 of 2. I used this selector: #gallery li:nth-....() { clear: left; }

2 Answers

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

putting that inside the media query should work.

What is the difference between:

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

and:

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

Thanks in advance for an answer.

Keith Kelly
Keith Kelly
21,326 Points

If you write the expression with only a 4, then it will select the 4th element and only the 4th element. If you use 4n it will select the 4th, 8th, 12th, ect. elements.

mrx3
mrx3
8,742 Points

actually there's some notes that are at the bottom of the video. I messed up with someone else asking the same question, and I was pointed to the notes at the bottom of the video the code is supposed to be. I know you asked about the test, and what Travis wrote is correct. I just wanted you to be aware of the fact, I'm just trying to be kind.

#gallery li:nth-child(3n+1) {
   clear: left;
}