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 Adjust the Profile Page and Header

Clearfix ?

What about .clearfix {display: inline-block;}

Is it a better than using nth-child ()

thank you

1 Answer

Erik Nuber
Erik Nuber
20,629 Points

These are for two different purposes. Clearfix allows you to correct collapsing floats. nth-child() is a selector that allows you to select a certain pattern you provide like nth-child(2n+1) will select every odd item. So they aren't relatable as far as I know. Just to be clear about why it would grab the odd item,

2x0 + 1 = 1

2x1 + 1 = 3

2x2 + 1 = 5...etc

oh. make sense. Thanks Erik. the thought process on the odd item is very useful.

I just started Treehouse, long way to go~

Cheers,