HTML/CSSAdvanced#css#float

How do you clear floats without adding extra markup?

Use the clearfix technique — a pseudo-element on the container with content: '' and clear: both — or simply set the parent to display: flow-root, which creates a new block formatting context that naturally contains floats.

Example
.container { display: flow-root; }
/* or classic clearfix */
.container::after { content: ""; display: block; clear: both; }

Related Questions

1
HTML/CSSBeginner#css#flexbox

Explain Flexbox: main axis vs cross axis.

Open
2
HTML/CSSIntermediate#css#flexbox

What do flex-grow, flex-shrink, and flex-basis do?

Open
3
HTML/CSSBeginner#css#flexbox

How do you center a div both horizontally and vertically?

Open