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 Basics Page Layout with the Float Property The Float Challenge

ClearFix: Table Vs. Block

For this Challenge, in my clearfix, I thought I would try using a value of "block" for the display property, and of course it worked. Why is "table" the value used for the various clearfixes I've found online? What is the advantage of "table" over "block"?

1 Answer

I think your answer can be found at this link: Using display: block (instead of display: table) allows margins to collapse properly when elements with clearfix are siblings.

But I think there's a newer, simpler way of doing the same thing: display: flow-root

I guess instead of using:

.container1::after {
  content: "";
  display: block;
  clear: both;
}

You can now just use:

.container1 {
  display: flow-root;
}

And it will do (almost) the exact same thing. See here: "display:flow-root" vs. "clearfix"