Is there something technically incorrect about floating and clearing in a single DIV? For example float:left
begins a box formatting context and clear:both
ends a box formatting context. Placing both in a single DIV
appears to create a self contained BFC not unlike overflow:hidden
.
Here is a simple example:
.wrapper {
width: 50%;
float: left;
clear: both;
}
I tested this in every modern browser except Safari because I don't have an iPhone handy. I also tested it in IE8 through 11. In all cases it worked perfect. In addition it validated properly on CSS Lint. But I wonder if I'm missing something. If this is proper and if it works why do so many people use the clearfix hack? Maybe I'm missing something obvious?