CSS Text Flow Around Image
This page shows you how to use CSS so that text wraps around image, using CSS
Here's a example:
The Time Traveller (for so it will be convenient to speak of him) was expounding a recondite matter to us. His grey eyes shone and twinkled, and his usually pale face was flushed and animated. The fire burned brightly, and the soft radiance of the incandescent lights in the lilies of silver caught the bubbles that flashed and passed in our glasses. Our chairs, being his patents, embraced and caressed us rather than submitted to be sat upon, and there was that luxurious after-dinner atmosphere when thought runs gracefully free of the trammels of precision. And he put it to us in this way—marking the points with a lean forefinger—as we sat and lazily admired his earnestness over this new paradox (as we thought it) and his fecundity. (from Time Machine.)
You can see the text flow around a image. This is done by making the image float with attribute
Here's the HTML:
<p> <img id="float_86944" src="lilies.png" alt="lilies" width="167" height="106"> The Time Traveller … </p>
The CSS code is this:
float can have a value of
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 a sequence of
<img …> elements, flowing from left to right.
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>
<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>
clear can have values of
Usually, it is best to use this element to clear the floats:
<hr style="visibility:hidden; clear:both">
Visual formatting model#propdef-float
If you have a question, put $5 at patreon and message me.