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!
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

Ivana Lescesen
19,442 PointsIs it better to use multiple classes or use nth-child(n) selector?
i have a few images I need to position to fit into a box, it does not seem efficient to a make class for each one so is this a better solution
<div class="box-4">
<p class="sbc">Complete</p>
<p> weight loss system</p>
<img src="images/box-image.png">
<a href="#"> <img src="images/arrow-side.png"> </a>
</div>
.box-4 img:nth-child(3){
height: 65%;
position: relative;
bottom: 10px;
}
.box-4 a img:nth-child(1) {
position: relative;
left: 28px;
bottom: 30px;
}
I have six boxes with the same code
1 Answer

Patryk Bernasiewicz
Courses Plus Student 10,281 PointsIt really depends on your own preference, although :nth-child will be more efficient and let you keep your HTML code cleaner. The :nth-child CSS selector is a widely supported feature and you can use it without worries.
You can visit these pages for reference:
And you can also test your :nth-child arguments on this site:
Ivana Lescesen
19,442 PointsIvana Lescesen
19,442 PointsThank you so much :)