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

CSS CSS Basics (2014) Basic Layout Clearing Floats

Isn't there an updated (better) solution to this clear fix?

I seem to remember a newer/better way to do this using a common clear fix...

code looks like:

.cf:before, .cf:after { content: ""; display: table; } .cf:after { clear: both; }

I do not know the difference but some research shows it is a "better" way to go about doing it? Just curious.

1 Answer

Tim Knight
Tim Knight
28,888 Points

Phil,

Yeah there are a few ways you can approach this. Clearfix is still pretty common and isn't consider an anti-pattern. Another option depending on what you're doing is setting the overflow of the parent to auto.