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 Floats

Clear:both question

I understand why we're applying clear: both to a parent element whose child-divs cause its height to collapse, but why is the clear:both grouped with other properties like this (with 'content' and 'display')?

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

}

Also what does the pseudo class :after do?

Thank you! Stephanie

1 Answer

Jason DeValadares
Jason DeValadares
7,190 Points

My understanding is it creates a "fake" child element for the class you're working on. This way it auto clears the float from anything following it: https://developer.mozilla.org/en-US/docs/Web/CSS/::after

Also commonly referred to as a 'clearfix'.