CSS clearance 2026-11-05
CSS clearance is the spacing introduced by the clear rules when a block's border edge must be placed below relevant earlier CSS floats. The calculation considers its hypothetical position and the floats to be cleared. It is a layout effect rather than a replacement for the block's declared margin.[ref]
For a simple horizontal-text example, take a left float whose bottom outer edge is at vertical coordinate CSS pixels. A following block would normally have its top border edge at coordinate . With clear: left and zero vertical margins, the needed displacement is
pixels. If a relevant right float instead extends to , clear: both requires the border edge to reach that lower boundary, giving pixels in the same simplified geometry.
The relevant edge includes the float's margin geometry; its content height alone is not always the correct reference. Clearing also concerns floats in the applicable CSS block formatting context, rather than every floated element anywhere in the document.
Margins make the general rule subtler. Introducing clearance inhibits the relevant CSS margin collapsing, so one cannot universally calculate it by adding an ordinary positive gap after all margins have already been collapsed. CSS2.2 explicitly permits zero or negative clearance. Its negative-clearance example separates previously collapsing margins and computes the correction needed for the final border-edge position.[ref]
A useful layout check records the hypothetical border position, the relevant float bottom edges, margins and the context boundary. Changing clear then tests a specific float-separation requirement; changing arbitrary padding until the page looks right can conceal a different cause.
CSS float 2026-11-05
A CSS float is a box shifted toward the left or right under the applicable flow rules, allowing surrounding inline content to wrap beside it. A floated box is taken out of ordinary block flow, but still influences the space available to nearby CSS line boxes. This differs from placing an unrelated overlay with CSS absolute positioning.[ref]
For an illustrative horizontal layout, a container is CSS pixels wide and a left float has width , height , and zero margins, padding and borders. Lines next to the float have pixels of horizontal space, provided no other float or constraint reduces it. Below the float's bottom, a line can again use the full pixels. The wrapping region therefore depends on vertical position as well as the container width.
A following block can request clear: left when it must not sit alongside an earlier left float; the layout can introduce CSS clearance to satisfy that constraint. This changes placement rather than deleting or resizing the float.[ref]
The floated box also establishes a CSS block formatting context for its own contents. Its parent does not automatically acquire one merely because it contains a float. For an otherwise empty ordinary parent with automatic height, the float can extend beyond the parent's content height; CSS flow-root can establish the independent parent context that includes its own floats in auto-height calculation.
Use floats when interaction with surrounding flow is intended. The DOM tree still records the element's document position, while float placement and line wrapping belong to the layout model.