CSS Text Flow Around Image
This page shows you how to use CSS so that text wraps around image, using CSS float
property.
Text Flow Around Image Example

You can see the text flow around a image. This is done by making the image float with attribute float
.
Here's HTML:
<div id="box29960"> <img id="imgfloat23699" src="i/tile_B.png" alt="tile B" width="128" height="128" /> <div> The Time Traveller (for so it will be convenient to speak of him) was expounding a recondite matter to us… </div> </div>
Here's CSS:
#imgfloat23699 { float:left; margin:8px; } #box29960 { max-width:400px; }
The float
can have a value of left
or right
.
When it's left, it aligns to the left.
When a element is floating, anything will go around it to avoid collision or overlap.
(except elements that have their own layer with position
. [see CSS Position: static, relative, fixed, absolute])
You can have multiple consecutive HTML elements that are all float:left
, then they'll behave as sequence of of inline-block
elements suchas <img …>
, flowing from left to right.
Stop Flowing
If you have many floating elements, the position of the last item will be the position the next non-floating item begin. For example, you might have:
floatElement floatElement floatElement … <h2>…</h2>
The <h2>
will be shown at the position right after the last flow, as if it is part of the flow.
If you don't want that, you need to stop the flow with clear:left
in the element that comes after the float. Like this:
<h2 style="clear:both">A New Beginning</h2>
The clear
can have values of left
, right
, both
.
Usually, it is best to use this element to clear the floats:
<hr style="visibility:hidden; clear:both">