CSS Float Summary

Float moves an element to the left or right so nearby inline content can wrap around it.

img {
	float: left;
	margin-right: 16px;
}

Float was once used for whole page layouts. Modern CSS usually uses Flexbox or Grid for layout instead. Float is still useful for wrapping text around an image.

Float Pulls An Element To One Side

A floated element moves to the left or right of its container. Text and inline content can flow beside it.

.photo {
	float: right;
	margin-left: 20px;
	width: 200px;
}

The margin creates space between the image and the text that wraps around it.

Clear Stops Wrapping

The clear property prevents an element from sitting beside a floated element.

.next-section {
	clear: both;
}

The Clear lesson explains this relationship in more detail.

Use Modern Layout For Page Structure

Use float for simple text wrapping. Use Flexbox or Grid when you need to arrange page sections, cards, columns, or navigation.

Interactive Demo

Image

Float moves a small box to one side so this paragraph can wrap around it. The text fills the open space beside the box and then continues underneath it.

Code Sandbox

AI Tutor