Wrapping text around an image in HTML is one of those skills that looks trivial until you actually try it. You drop an <img> tag into a paragraph, expect the words to flow neatly beside it, and instead the image sits stubbornly on its own line while the text marches below it. The fix is not complicated, but it does require understanding how CSS handles document flow—and knowing which of the several available techniques fits your layout Small thing, real impact..
This guide walks through the classic float method, the modern alternatives, the pitfalls that trip up beginners, and the accessibility details that make the difference between a page that merely looks fine and one that performs well in search results.
Why Wrapping Text Around Images Matters
Text wrapping is not just decoration. In practice, a block of unbroken text spanning the full width of a desktop screen is hard to read; the eye loses its place when lines run past roughly 75 characters. Placing an image inside the text column and letting the copy flow around it tightens the measure, breaks up visual monotony, and creates a natural entry point for the reader's attention.
Real talk — this step gets skipped all the time.
From an editorial standpoint, wrapped images are also efficient. They use horizontal space that would otherwise sit empty, which is especially valuable in article layouts, blog posts, product descriptions, and newsletter-style pages. And from a technical standpoint, the technique is lightweight—no JavaScript, no extra markup, just a few lines of CSS Easy to understand, harder to ignore..
The Classic Method: CSS Float
The float property remains the most direct way to wrap text around an image. When you float an element, it is taken out of the normal vertical flow and pushed to the left or right edge of its container, and the inline content that follows—your paragraphs—wraps around it.
Basic Float Syntax
Long-form copy begins here and flows around the image...
Additional paragraphs continue to wrap until the image height is cleared Most people skip this — try not to..
.wrap-left {
float: left;
width: 320px;
max-width: 45%;
height: auto;
margin: 0 1.25rem 0.75rem 0;
border-radius: 8px;
}
Three details in that snippet do most of the work:
float: leftpushes the image to the left edge and lets text occupy the remaining space.max-width: 45%keeps the image from swallowing the text column on narrow screens.margincreates breathing room. Without it, the text butts directly against the image and the layout feels cramped.
Use float: right for the mirror effect, and alternate sides across a long article to create rhythm It's one of those things that adds up..
Clearing the Float
Here is where most beginners get stuck. A floated element is removed from normal flow, so its parent container may collapse to zero height, causing backgrounds, borders, and following sections to overlap the image Surprisingly effective..
The modern fix is a single declaration:
.post {
display: flow-root;
}
display: flow-root establishes a new block formatting context, which contains the float cleanly without any hacks. If you need broader browser support, the classic clearfix still works:
.post::after {
content: "";
display: block;
clear: both;
}
You can also apply clear: both directly to the element that should appear below the image, such as a footer or a new section heading.
Adding Polish
Small refinements make wrapped images feel intentional rather than accidental:
- Add
border-radiusfor softened corners. - Apply a subtle
box-shadowfor depth. - Use
object-fit: coverwith a fixed height if you need consistent image dimensions. - Set
shape-marginwhen usingshape-outsideto control the gap between the text and the shape edge.
Modern Alternatives Worth Knowing
Float is not the only tool, and it is not always the right one. Understanding the alternatives helps you choose deliberately.
Flexbox
Flexbox places the image and text side by side as flex items. Worth adding: the critical difference: text does not wrap around the image—it forms its own column beside it. Flexbox is ideal for card layouts, media objects, and feature blocks where you want a clean two-column split rather than flowing prose Not complicated — just consistent..
.media {
display: flex;
gap: 1.5rem;
align-items: flex-start;
}
CSS Grid
Grid offers the same block-level behavior with more control over alignment and sizing. On the flip side, use it when you need precise column ratios or when the layout must adapt across breakpoints. Like Flexbox, it does not produce true text wrapping But it adds up..
shape-outside for Organic Wrapping
If you want text to follow the contour of a circular portrait or a diagonal graphic, shape-outside is the answer. It requires a floated element, which is the detail people most often miss.
.portrait {
float: left;
width: 260px;