Float hasn't been removed — its role has narrowed
The question of whether float should still be written today comes up regularly now that Grid and Flexbox are available. The practical answer: keep it for text wrapping around images, and avoid it for layout. The CSS Grid and Flexbox story is that replacing float-based layout with the newer tools is preferable — not that the old declaration is broken.
Why float was never a layout tool
Before flexbox and grid, float was what designers reached for to build grids and page layouts; for many it was the first piece of CSS learned, moving a small div with float: right. That facility made it popular, but using it for complex layouts was always a hack. The property was designed for one job: letting text wrap around an image.
img {
width: 150px;
float: left;
}
Problems only emerge once float is pushed into large layouts and magazine-style grids — which was the norm when there were no alternatives.
The clearfix hack
One recurring issue is the need to wrap floated elements in a clearfix. Jay Hoffman described the origin of that pattern:
The clearfix, for those unaware, is a CSS hack that solves a persistent bug that occurs when two floated elements are stacked next to each other. When elements are aligned this way, the parent container ends up with a height of 0, and it can easily wreak havoc on a layout. All you might be trying to do is position a sidebar to the left of your main content block, but the result would be two elements that overlap and collapse on each other. To complicate things further, the bug is inconsistent across browsers. The clearfix was invented to solve all that.
<div class="clearfix">
<div class="float-left">Column</div>
<div class="float-left">Column</div>
<div class="float-left">Column</div>
</div>
clearfix:after {
content: "";
display: table;
clear: both;
}
A native replacement
Rachel Andrew explained in 2017 that browsers can handle the clearfix problem without any hacks at all. The equivalent CSS is:
.container {
display: flow-root;
}
The existence of flow-root is itself an argument: with CSS Grid and Flexbox we don't really need float at all. It was designed to do one thing, and grid and flexbox now handle the heavy lifting for real layouts.
Don't purge it
A common reaction is to delete every float from a codebase, on the grounds that it is old code easily swapped for flexbox or grid. That is overkill: a few float declarations do no real harm and are not radioactive code causing problems.
So use float for nothing beyond text wrapping? Yes. Purge the web of float declarations because they aren't the "correct" way? No. Old code shouldn't break things — a site that skips the newest CSS isn't useless or bad. float has simply been superseded by better alternatives, and properties like it are likely to stick around because they still have applicable uses in modern web design.



