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

David Bath
David Bath
25,940 Points

"Clearfix" display value

In Guil's video on clearing floats he uses this standard rule:

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

I've seen this before, but I don't understand why the value for display is "table" as opposed to "block". Both values seem to have the same effect, but "block" seems more intuitive to me. I'm wondering if there is a reason to use "table" instead, such as some rendering issue I didn't notice.

1 Answer

The main reason to always use display: table; rather than display: block; I belive is because of the elements children.

Using the table display you can safely have child elements without fear of the clearfix effecting it's child elements display.