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 Build a Three Column Layout

nth-child: 4n vs 4

Why are we supposed to use 4n instead on 4? What is so special about this n?

1 Answer

Jeff Lemay
Jeff Lemay
14,268 Points

If you only used "4", you'd only affect the 4th element but not the 8th, 12th, 16th, etc.

The "n", which starts at 0, is like doing 4x0=nothing, 4x1=4, 4x2=8, 4x3=12, 4x4=16, etc.

Thank you! I tought about that, but I wasn't sure.