CSS Shapes
CSS Shapes, via the shape-outside property, let inline content (text) wrap around a non-rectangular shape instead of the usual rectangular box. Normally, when text wraps around a floated image, it follows the image's bounding box — even if the image itself is a circular avatar or an irregular illustration, the text still stops at an invisible rectangle around it. shape-outside tells the text to instead follow a circle, polygon, or the actual opaque pixels of an image.
The classic use case — text around a circular avatar
.profile-photo {
float: left;
width: 180px;
height: 180px;
border-radius: 50%;
margin-right: 16px;
/* Without this, text would wrap around the square bounding
box, leaving visible gaps at the circle's rounded corners */
shape-outside: circle(50%);
}Paragraph text after this floated image now curves inward to hug the circle's actual edge, instead of stopping at a straight vertical line at the image's right edge. The result reads like a magazine layout, with text flowing naturally around a portrait photo.
Polygon shapes for irregular wrapping
.diamond-graphic {
float: left;
width: 200px;
height: 200px;
margin-right: 20px;
shape-outside: polygon(
50% 0%,
100% 50%,
50% 100%,
0% 50%
);
/* Text now flows around a diamond, following the polygon's
edges rather than the element's rectangular box */
}Shaping from an image's actual alpha channel
.leaf-illustration {
float: right;
width: 240px;
shape-outside: url('/images/leaf-silhouette.png');
shape-image-threshold: 0.5; /* alpha cutoff for what counts as "shape" */
shape-margin: 12px; /* gap between text and the shape's edge */
}Here the wrap follows the actual opaque silhouette of the PNG (subject to shape-image-threshold's alpha cutoff), so text curves around the leaf's organic outline rather than any geometric approximation of it.