Float Values and Element Behavior
You'll learn: How the three float values control element positioning and how floating removes elements from normal document flow.
The Three Float Values
CSS provides three values for the float property:
left– The element floats to the left side of its container, and other content wraps around its right sideright– The element floats to the right side of its container, and other content wraps around its left sidenone– Default value; the element does not float and remains in normal flow
Removed from Normal Flow
When you apply float: left or float: right, something important happens: the element is removed from the normal document flow.
Think of it like lifting a picture off a page and sliding it to one side. The text that was below the picture can now flow up and around it. The floated element still occupies space horizontally where other content wraps, but it no longer pushes down elements below it the way block elements normally do.
.sidebar {
float: left;
width: 200px;
}
.main-content {
float: none; /* stays in normal flow */
}
The sidebar floats left and content flows around it. Meanwhile, any element with float: none behaves normally—staying in the document flow just like you learned in the Normal Flow lessons.
Visual Behavior
Floated elements shift as far left or right as possible within their containing block, stopping only when they hit the container's edge or another floated element.
Key Takeaway: Float accepts left, right, or none; floated elements are removed from normal flow, allowing other content to wrap around them while they sit anchored to one side of their container.