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 Layout Techniques Float Layout The Float Clearfix

Clearfix!!!

.group::after { content: " "; display: table; clear: both; }

Why does ::after and content and why display: table????

2 Answers

Jacob Miller
Jacob Miller
12,466 Points

::after because you're adding a block element after the floated element so it causes a line break and keeps other floated elements below it. content: "" because you don't actually want to add any content, just a line break. display: table because this will cause a line break. You can also use display: block. clear: both because you want to push both left and right floated elements down below the element with the clearfix.

Hello Jacob, Thank you for the answers. I suspected that it was to create some kind of a break but why use all three methods to create a line break? I am also assuming that we create this new class so that it can be reused in other places.