Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

Chase Gonzales
Chase Gonzales
1,920 Points

what exactly does the (4n) stand for?

what exactly does the (4n) stand for?

1 Answer

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,258 Points

the 4n means every 4th element. the syntax is an + b, where a and b are integers and the first index is 1. some examples from the docs: n is every element, 2n is every other element, the evens, 2n+1 is every other element, but starting at 1, so the odds, 3n+4 is every 3rd element, starting at element 4, so 4, 7, 10 etc. you can also use 0n + b to select a particular element, so 5 would be the fifth element only, 2 would be the second element only, etc.