Websites and banners, made understandableImages · Code · WordPress
Home / Guides
HTML & design

Wrap text around an image without breaking the page

Float is appropriate when text lines should genuinely wrap around artwork. Use Grid or Flexbox for two independent columns.

Before you begin

Provide real width/height and useful alt text. Check the unstyled document order first: image and explanation should follow a logical sequence.

Wrap text around an image without breaking the page. Wide: float → Wrapper: flow-root → Phone: separate block
Wide: float → Wrapper: flow-root → Phone: separate block
Text explanation of the diagram

Wide: float → Wrapper: flow-root → Phone: separate block. A 220 px illustration plus a 24 px gap leaves 456 px for text inside a 700 px column. On a 360 px screen this becomes too narrow, so the image should occupy its own block.

The procedure

  1. On wide layouts, apply float: left, a limited width and right/bottom margins. Do not let the image become wider than the text container.
  2. Give the wrapper display: flow-root so the float does not spill into the next section. Remove the float on narrow screens and let the image use available width.
  3. Test a short paragraph, a long heading and enlarged text. The next section should not unexpectedly sit beside the image.
Code example
.story { display: flow-root; }
.story img { float: left; width: 220px; max-width: 100%; margin: 0 24px 16px 0; }
@media (max-width: 600px) { .story img { float: none; margin: 0 0 16px; } }

A worked example

A 220 px illustration plus a 24 px gap leaves 456 px for text inside a 700 px column. On a 360 px screen this becomes too narrow, so the image should occupy its own block.

Check the result

There are no one-word text strips, horizontal scrolling or collisions with the next heading. Keyboard and unstyled reading order remains logical.

A common mistake

A fixed image width plus large margins can exceed the viewport. max-width does not automatically remove external spacing.

Sources and next steps

Diagram and examples: Web Article editorial team. The diagram explains a principle; it is not an interface capture or a software test result.

Keep making