Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.