liveBook · Manning

Shape-outside

As explained in CSS in Depth, Second Edition

The CSS shape-outside property defines the shape around which inline content may flow, typically for a floated element.

The CSS shape-outside property defines the shape around which inline content flows. It works only on a floated element, whose position lets text flow beside it instead of following a straight rectangular edge. section 14.4

Listing 14.15 A circle clip path and shape
.poem-image {
  float: left;
  margin-right: 15px;
  --shape: circle(50%);
  clip-path: var(--shape);
  shape-outside: var(--shape);
}

.poem-image > img {
  display: block;
  height: 350px;
  width: 350px;
  object-fit: cover;
}

A reusable circle pattern shares one custom property between clip-path and shape-outside, keeping the visible image and text boundary aligned. section 14.4.2

Use shape-outside to coordinate visible contours, wrapping space, and layout behavior:

  • Pair it with clip-path, mask, or border-radius when the element’s visible appearance should match the text-wrapping contour. section 14.4 section 14.5
  • Use circle(), ellipse(), polygon(), inset(), or a reference box such as margin-box; path() is specified but unsupported in browsers described here. section 14.4.2
  • Add shape-margin when wrapped text needs space along the contour, remembering that it cannot extend beyond the floated element’s margin box. section 14.4.2
  • Use a gradient as the shared mask and shape when the desired contour is diagonal or follows an image threshold. section 14.4.2

Circular image with matching text flow

Float the image container, define --shape: circle(50%), and assign that value to both clip-path and shape-outside. Add a margin or shape-margin to separate the text from the circle. section 14.4.2

How CSS in Depth, Second Edition covers it

How deep it goes
Explains float dependency, shape values, shared contours, spacing limits, gradients, and unsupported path() without descending into browser internals.
Examples
Demonstrates circular eagle imagery, border-radius circles, diagonal gradients, and opacity-threshold shapes for wrapped text.
What it assumes
Assumes familiarity with floats and basic CSS masking, clipping, border-radius, gradients, and custom properties.
What you can do after
Apply it via CSS to make inline text follow circles, polygons, gradients, masks, or other supported shapes around floated elements.
How it connects
Connects shape-outside with floats, clip-path, masks, border-radius, shape-margin, gradients, and CSS custom properties.

Also explained in

Compare how 2 books explain shape-outside →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.