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

mohammed abdi abdulahi warsame
mohammed abdi abdulahi warsame
4,926 Points

why 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.
Erik S.
9,789 Points

Hi 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
mohammed abdi abdulahi warsame
4,926 Points

thanks alot i think i can use this when i want to apply it in my website

Erik S.
Erik S.
9,789 Points

Great, good luck for your website!