Lesson 31 of 50
cssCSS Shapes – Non‑Rectangular Layout
8 mins
Course progress62%
What you'll learn
Keep this idea in mind as you work through the lesson.
Lesson 31 of 50
css8 mins
Keep this idea in mind as you work through the lesson.
The shape-outside property lets text flow around an arbitrary shape instead of the default rectangular box. It works only on floated elements.
.float {
float:left; /* must be floated */
width:200px; height:200px;
shape-outside:circle(50% at 50% 50%); /* a perfect circle */
clip-path:circle(50% at 50% 50%); /* optional visual cropping */
}
circle(), ellipse(), polygon(), or even an image with url() (supported in Chrome & Safari).clip-path is purely visual; shape-outside tells the layout engine how to wrap text.<img src="portrait.jpg" alt="Portrait" class="avatar" />
<p>Long paragraph that elegantly wraps around the circular portrait, creating a magazine‑style feel.</p>
.avatar {
float:left;
margin:0 1rem 1rem 0;
width:150px; height:150px;
shape-outside:circle(50% at 50% 50%);
clip-path:circle(50% at 50% 50%);
}
shape-outside works, but clip-path may not.polygon() for Custom Shapes.shape {
shape-outside:polygon(0 0, 100% 0, 100% 70%, 0 100%);
}
shape-outside does not affect assistive technology. The content is still read linearly, so ensure the surrounding text remains understandable.