float: left or right (or the logical inline-start and inline-end) takes a box out of normal flow and shifts it to that edge of its containing block, as high as it can go without overlapping earlier floats. The float becomes a block box (its display is blockified) and, without an explicit width, is shrink-to-fit: as wide as its content needs.
Content after the float reacts in two different ways:
- Line boxes shorten. Text in following blocks flows beside the float, then back to full width below it.
- Block boxes don't move. A paragraph after the float starts at the container's edge, underneath the float; only its text is pushed aside. Its background and border run behind the float. A block that establishes a BFC is the exception: it narrows to sit beside the float.
Floats stack along their side. When the next float doesn't fit in the remaining width, it moves down to the first place it fits.
clear: left | right | both (or inline-start, inline-end) on a block says "start below earlier floats on that side". The browser adds clearance above the block's top margin, enough to put its border edge below the float. The margin is absorbed into that space rather than added to it.
Two related problems: a parent doesn't grow to contain its floats unless it's a BFC root (fix with display: flow-root), and floats have no effect on flex or grid items.
Where floats still belong: wrapping text around an image, a pull quote, or a figure in an article, the one thing flex and grid can't do. shape-outside lets the text follow a circle, polygon or image alpha instead of the rectangle. For page layout, columns and sidebars, use flex or grid.