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 trialmohammed abdi abdulahi warsame
4,926 Pointswhy is nth child applays only on specific numbers?
i want to applay the nth child in each of my pictures that run out of the line not only the 4th or 8th!!
2 Answers
Erik S.
9,789 PointsHi Mohammed, you can also use a formula with nth-child. It has this form:
img:nth-child(an+b) {}
Where a is the cycle size, n is a counter (starts at 0), and b is an offset value. So if you want to adress every second image for example , you can use:
img:nth-child(2n+0) {}
mohammed abdi abdulahi warsame
4,926 Pointsthanks alot i think i can use this when i want to apply it in my website
Erik S.
9,789 PointsGreat, good luck for your website!