ClearFix vs Overflow [duplicate]

The only time you should bother using the “clearfix” method that inserts invisible content to clear is if you need an element to be visible when it overflows the element you’re applying it to, otherwise triggering hasLayout + overflow is golden.

Note that in IE7 overflow hidden triggers hasLayout. Not sure about IE8.

#wrapper { width:80em; overflow:hidden; }

The method above will work fine in most all cases unless you need say, #header to overflow past #wrapper..

#wrapper { width:80em; position:relative; }
#wrapper:after {  content:"."; clear:both; display:block; height:0; visibility:hidden; }
#header { position:absolute; top:-15px; left:-15px; }

Leave a Comment