CSS Shapes and clip-path: Wrapping Text with shape-outside and Polygons0%
CSS Multi-Column Layouts: Newspaper Columns, Gaps, and Column Rules

CSS Shapes and clip-path: Wrapping Text with shape-outside and Polygons

Advanced14 min readUpdated: 2026-09-10
Study Materials

CSS Shapes and clip-path: Wrapping Text with shape-outside and Polygons

For decades, the web has been held captive by rectangles. Every HTML element—whether an image, a button, or a paragraph—is rendered by default as an invisible rectangular box. Even if you apply border-radius: 50% to make an image look circular, surrounding text still wraps around the invisible rectangular bounding box, leaving awkward empty corners.

In printed school annual magazines and professional editorial publications, text wraps organically around circular author portraits, diagonal banners, and geometric illustrations. With modern CSS clip-path and shape-outside, you can break free from the prison of rectangular boxes and craft true organic, magazine-quality layouts!


1. clip-path vs shape-outside: The Mental Model

These two properties sound similar, but they perform two completely different, complementary jobs:

Visual Architecture Blueprint
+-------------------------------------------------------------------------+
|                  CLIP-PATH VS SHAPE-OUTSIDE ARCHITECTURE                |
+-------------------------------------------------------------------------+

  1. clip-path: polygon(...)
     [Controls the ELEMENT'S OWN VISUAL CUTOUT]
     Acts like a pair of scissors cutting into the image.
     Only the interior of the shape is visible; outer pixels are clipped.

  2. shape-outside: circle(...)
     [Controls HOW OUTSIDE TEXT WRAPS AROUND THE ELEMENT]
     Tells neighboring inline text to curve smoothly along the contour
     instead of staying boxed out by a rectangular boundary.

2. The Power of clip-path

The clip-path property defines a specific clipping region. Pixels inside the shape are drawn; pixels outside are transparent and do not respond to pointer events:

Standard Clip Shapes:

CSS
/* 1. Perfect Circle: circle(radius at center-X center-Y) */
.avatar-circle {
clip-path: circle(50% at 50% 50%);
}
 
/* 2. Ellipse: ellipse(radius-X radius-Y at center-X center-Y) */
.badge-ellipse {
clip-path: ellipse(60% 40% at 50% 50%);
}
 
/* 3. Inset Box with rounded corners: inset(top right bottom left round radius) */
.card-inset {
clip-path: inset(10px 20px 10px 20px round 16px);
}

Complex Polygons: polygon(x1 y1, x2 y2, ...)

You can plot pairs of $X$ and $Y$ percentage coordinates to carve custom geometric polygons:

CSS
/* Diagonal Slanted Section Header */
.slanted-banner {
clip-path: polygon(0% 0%, 100% 0%, 100% 85%, 0% 100%);
}
 
/* Chevron Arrow Ribbon */
.chevron-step {
clip-path: polygon(0% 0%, 85% 0%, 100% 50%, 85% 100%, 0% 100%, 15% 50%);
}

3. Organic Text Wrapping with shape-outside

When you float an image and give it border-radius: 50%, paragraph text still wraps in a square:

Visual Architecture Blueprint
+-------------------------------------------------------------------------+
|                  WITHOUT VS WITH SHAPE-OUTSIDE                          |
+-------------------------------------------------------------------------+

  WITHOUT shape-outside:
  +---------------+  The principal welcomed the incoming
  |   (PHOTO)     |  batch of class 11 students with great
  |  [Circular]   |  warmth. He spoke about academic rigor
  |   [Image]     |  and the importance of continuous curiosity...
  +---------------+  (Notice the wide, awkward rectangular gap!)

  WITH shape-outside: circle(50%):
     , - - - ,       The principal welcomed the incoming
   '   PHOTO   '     batch of class 11 students with great
  (  [Circular] )    warmth. He spoke about academic rigor
   '   Image   '     and the importance of continuous curiosity...
     ' - - - '       (Text curves gracefully along the round edge!)

The 3 Golden Rules of shape-outside:

  1. 1
    The element MUST be floated (float: left or float: right). Shapes do not affect text wrapping on non-floated block containers.
  2. 2
    The element MUST have explicit dimensions (width and height).
  3. 3
    Use shape-margin to provide breathing room between the curved boundary and the surrounding words.
CSS
.principal-avatar {
float: left;
width: 180px;
height: 180px;
border-radius: 50%;
margin-right: 24px;
/* 1. Cut the image visually into a circle */
clip-path: circle(50%);
/* 2. Direct surrounding text to wrap along the circular contour */
shape-outside: circle(50%);
/* 3. Add 16px of clearance around the curved boundary */
shape-margin: 16px;
}

4. Wrapping Text Around Polygons and Slanted Dividers

shape-outside is not restricted to circles. You can wrap text along diagonal slashes or triangles:

CSS
.triangle-float {
float: left;
width: 200px;
height: 250px;
/* Both visual clip and external wrap shape match! */
clip-path: polygon(0 0, 100% 0, 0 100%);
shape-outside: polygon(0 0, 100% 0, 0 100%);
shape-margin: 20px;
}

5. Wrapping Around Transparent Images: shape-outside: url()

Did you know you can tell CSS to automatically wrap text around the transparent pixels of a PNG or SVG graphic without writing mathematical coordinates?

CSS
.science-trophy {
float: right;
width: 220px;
height: 260px;
/* Uses the image's own alpha transparency channel as the wrap contour! */
shape-outside: url('trophy-cutout.png');
shape-image-threshold: 0.5; /* Wrap at 50% opacity threshold */
shape-margin: 20px;
}
Note
When using shape-outside: url(...), the image must be hosted on the same origin (or served with proper CORS headers), otherwise browser security policies will block pixel inspection.

6. Animating clip-path Transitions

Because clip-path values can be interpolated, you can morph one polygon into another during hover interactions!

Rule for Polygon Morphing: Both polygons must have the exact same number of coordinate points! You cannot morph a 3-point triangle into a 6-point star directly.
CSS
.reveal-badge {
/* Starts clipped as an inset box */
clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
transition: clip-path 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
 
.reveal-badge:hover {
/* Morphs into a dynamic angled diamond (4 points to 4 points) */
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

7. Do's and Don'ts

PracticeBad ApproachGood ApproachWhy It Matters
Floating for ShapesForgetting float: left/right when applying shape-outsideAlways floating the elementshape-outside has zero effect on text wrapping unless the element is floated.
Polygon MorphingTransitioning between a 4-point shape and a 5-point shapeEnsuring identical coordinate counts between statesMismatched vertex counts break browser interpolation and snap abruptly.
Shadows on Clipped ElementsApplying box-shadow on an element with clip-pathApplying filter: drop-shadow(...) on a parent wrapperclip-path cuts off standard box-shadow pixels outside the boundary.
Spacing Around ShapesUsing traditional margin to push text away from shapesUsing shape-marginshape-margin expands the radial curved boundary rather than an invisible rectangle.

8. Quick Revision Summary Cheat Sheet

  • clip-path: Cuts the visible boundary of the element (interior stays, exterior is clipped).
  • shape-outside: Defines the contour line along which neighboring inline text wraps.
  • Float Requirement: shape-outside requires float: left or float: right.
  • shape-margin: Creates fluid breathing room along the curved shape contour.
  • Image Alpha Wrapping: shape-outside: url(...) with shape-image-threshold: 0.5 wraps around transparent PNGs automatically.

Multiple Choice Questions

1. What is the key difference between clip-path and shape-outside?

A. clip-path only works on text, while shape-outside works on images B. clip-path cuts the element's own visible pixels, while shape-outside controls how external neighboring text wraps around the element C. clip-path requires JavaScript D. shape-outside is deprecated in modern CSS Answer: B Explanation: clip-path acts as a pair of scissors carving the element itself. shape-outside dictates the exclusion area where flowing paragraph text may not enter.


2. Which mandatory CSS property must be present on an element for shape-outside to take effect?

A. display: flex; B. position: fixed; C. float: left; or float: right; D. overflow: hidden; Answer: C Explanation: The CSS Shapes specification dictates that shape-outside only alters the geometry of exclusion areas for floated elements.


3. What requirement must be met to smoothly animate a clip-path: polygon(...) between two states?

A. Both polygons must have the exact same number of coordinate points B. The polygons must use hexadecimal color codes C. The element must be an SVG file D. The duration must exceed 5 seconds Answer: A Explanation: The browser can only interpolate intermediate vertex coordinates if both the starting and ending polygon declarations have an identical number of $(X, Y)$ coordinate pairs.


4. Which property provides spacing between a curved shape-outside contour and surrounding wrapped paragraph text?

A. margin B. padding C. shape-margin D. border-spacing Answer: C Explanation: Standard margin creates rectangular offset spacing, whereas shape-margin expands the curved exclusion contour directly.


5. Why does standard box-shadow fail to appear properly when placed on an element styled with clip-path?

A. The browser disables shadows on modern GPUs B. clip-path clips away any pixels outside the designated shape boundary, including the exterior blur of box-shadow C. box-shadow only supports squares D. clip-path converts the element to an image Answer: B Explanation: clip-path clips everything outside the path perimeter. To cast a shadow around a clipped shape, apply filter: drop-shadow(...) on a parent container.


Hands-on Practice Challenge

Build an editorial interview page for a school science magazine where paragraph text curves gracefully around a circular scientist portrait using shape-outside and clip-path.

Requirements:

  1. 1
    Float an author avatar image to the left with shape-outside: circle(50%);, clip-path: circle(50%);, and shape-margin: 20px;.
  2. 2
    Wrap a multi-line editorial interview quote around the portrait.
  3. 3
    Add a modern diagonal badge ribbon at the top using clip-path: polygon(0 0, 100% 0, 85% 100%, 0% 100%);.

Complete Solution:

HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Shapes & Editorial Wrapping</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Georgia', serif;
}
 
body {
min-height: 100vh;
background: #f8fafc;
color: #1e293b;
padding: 40px 20px;
display: flex;
justify-content: center;
align-items: center;
}
 
.article-container {
max-width: 680px;
background: #ffffff;
border-radius: 16px;
padding: 40px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
border: 1px solid #e2e8f0;
}
 
/* 1. DIAGONAL BADGE RIBBON USING CLIP-PATH */
.ribbon-tag {
display: inline-block;
padding: 6px 24px 6px 16px;
background: #0284c7;
color: #ffffff;
font-family: 'Segoe UI', sans-serif;
font-size: 0.8rem;
font-weight: 800;
letter-spacing: 1px;
text-transform: uppercase;
margin-bottom: 20px;
/* Cut trailing edge diagonally */
clip-path: polygon(0 0, 100% 0, 85% 100%, 0% 100%);
}
 
.article-headline {
font-size: 2rem;
font-weight: 700;
line-height: 1.25;
color: #0f172a;
margin-bottom: 24px;
}
 
/* 2. CIRCULAR TEXT WRAPPING VIA SHAPE-OUTSIDE */
.avatar-wrapper {
float: left;
width: 170px;
height: 170px;
margin-right: 24px;
margin-bottom: 12px;
/* Cut visual pixels into a circle */
clip-path: circle(50% at 50% 50%);
/* Curve outside flowing text along the 50% circle contour! */
shape-outside: circle(50% at 50% 50%);
/* 20px radial cushion between image edge and text */
shape-margin: 20px;
border: 4px solid #0284c7;
}
 
.avatar-wrapper img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
 
.article-body {
font-size: 1.05rem;
line-height: 1.8;
color: #334155;
text-align: justify;
}
 
.author-name {
font-family: 'Segoe UI', sans-serif;
font-size: 0.85rem;
font-weight: 700;
color: #64748b;
margin-top: 24px;
border-top: 1px solid #e2e8f0;
padding-top: 14px;
}
</style>
</head>
<body>
 
<article class="article-container">
<div class="ribbon-tag">Olympiad Feature</div>
<h1 class="article-headline">The Geometry of Quantum Computing</h1>
 
<!-- Floated image with circular shape-outside -->
<div class="avatar-wrapper">
<img
src="https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=400&auto=format&fit=crop&q=80"
alt="Author Portrait"
>
</div>
 
<!-- Wrapped text -->
<p class="article-body">
"When we observe physical reality at the nanoscale, the rigid rectangular boundaries of classical mathematics give way to probability waves and organic contours," explains Dr. Radhika Swaminathan, Senior Faculty at the National Science Institute. "Students must learn to look past two-dimensional textbooks and appreciate spatial harmony. Just as natural light diffracts smoothly around curvature, scientific curiosity should flow unhindered across physical disciplines."
</p>
 
<div class="author-name">
Reported by the Department of Physics &bull; Delhi Public Academy
</div>
</article>
 
</body>
</html>
Next Lesson

CSS Multi-Column Layouts: Newspaper Columns, Gaps, and Column Rules

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

PrevNext