Float Basics and Original Purpose
What you'll learn: How the float property was originally designed to wrap text around images, just like in print magazines.
The Original Intent
Before modern layout tools like Flexbox and Grid existed, CSS borrowed a concept from print design: floating elements to wrap content around them. Think of how a magazine article flows text around a photo—that's exactly what float was created to do.
When you apply float: left or float: right to an element (typically an image), it shifts that element to the left or right side of its container, and inline content (like text) flows around it. The floated element is removed from normal flow, allowing other content to wrap alongside it.
How It Works
Imagine you're reading a newspaper article with a photo. The photo sits on the left side, and the text wraps around its right edge, filling the available space. This is the fundamental behavior of floats:
float: left— Element moves to the left; content wraps on the rightfloat: right— Element moves to the right; content wraps on the leftfloat: none— Default; element stays in normal flow (no floating)
The floated element still occupies space horizontally, forcing surrounding inline content to flow around it, but block-level elements beneath it act as if the floated element isn't there (though their content wraps around it).
Why This Matters
Understanding float's original purpose helps you recognize when to use it (wrapping text around images) versus when modern layout methods are more appropriate. Floats were later repurposed for entire page layouts, but that wasn't their intended design.
Key Takeaway: The float property was designed to wrap text around images, mimicking traditional print layouts by pulling an element to one side while allowing content to flow around it.