π What Is shape-outside?
The shape-outside property allows you to define a custom shape that controls how inline content (like text) wraps around a floated element.
Instead of wrapping text around a plain rectangle, you can make it flow around a circle, polygon, or even an imageβs alpha channel.
This gives you magazine-style layouts, creative storytelling sections, and dynamic content flow. π°β¨
π§© Basic Requirements
β οΈ The element using shape-outside must be floatedβ float: left; or float: right;
Otherwise, the shape wonβt affect text flow.
π§© Basic Syntax
Syntax
shape-outside: <basic-shape> | <image> | <shape-box>;
shape-outside: circle(50%);
shape-outside: polygon(0 0, 100% 0, 100% 100%);
shape-outside: url(image.png);
shape-outside: inset(20px);β Shapes include: circle(), ellipse(), inset(), polygon()
β Images use their alpha channel to define wrap boundaries
β shape-margin adds spacing around the shape
π― The shape-outside βFlow Ruleβ
Text wraps outside the defined shape. If using an image, only non-transparent regions define the shape.
π§ͺ Example: Circle Text Wrap
Circle wrap
.circle {
float: left;
width: 200px;
height: 200px;
shape-outside: circle(50%);
clip-path: circle(50%); /* Optional: make visual shape match */
background: url(profile.jpg) center/cover;
}β Perfect for profile pictures in blog layouts
β clip-path makes the visible shape match the wrapping shape (recommended)
π§ͺ Example: Polygon Wrap
Polygon wrap
.triangle {
float: right;
width: 200px;
height: 200px;
shape-outside: polygon(50% 0, 0 100%, 100% 100%);
background: coral;
}β Text flows around a triangle β great for bold layouts.
π§ͺ Example: Using Images as Shapes
Image-based shape
.mask-shape {
float: left;
width: 220px;
height: 220px;
shape-outside: url(star.png);
shape-margin: 10px;
background: url(star.png) center/contain no-repeat;
}β PNG or SVG with transparency defines how text flows
β shape-margin gives breathing room around the star
π¨ Example: Heart-Shaped Text Flow
Heart wrap
.heart {
float: right;
width: 250px;
height: 250px;
shape-outside: path("M50,15 Q25,0 0,30 T50,60 T100,30 Q75,0 50,15 Z");
clip-path: path("M50,15 Q25,0 0,30 T50,60 T100,30 Q75,0 50,15 Z");
}β Organic shapes
β Beautiful for storytelling, magazine layouts, product designs
π§ shape-margin β Your Best Friend
shape-margin example
shape-margin: 20px;β Adds spacing between text and the wrap shape
β Prevents text from touching edges
π₯ Advanced Example: Irregular Image Wrap
Irregular wrap
.irregular {
float: left;
width: 300px;
height: 300px;
shape-outside: url(tree.png);
shape-margin: 15px;
background: url(tree.png) center/cover no-repeat;
}β Text wraps around the non-transparent silhouette of the image
β Stunning for nature or artistic layout designs
π Example: Combining clip-path + shape-outside
Consistent visual + wrap shape
.combined {
float: left;
width: 250px;
height: 250px;
shape-outside: circle(50%);
clip-path: circle(50%);
}β clip-path controls visible shape
β shape-outside controls text flow shape
β Together they create perfectly matched visuals
π§ Browser Support
- β Chrome
- β Safari
- β Edge
- β οΈ Firefox: partial support (no image shapes)
Note
π οΈ Debugging Tips
- If shape-outside has no effect β ensure the element is floated!
- Set explicit width & height on the shape element
- Use shape-margin for better text spacing
- Use clip-path alongside for visual alignment
- Try different values in DevTools for fine-tuning shape points