Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
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!
clip-path vs shape-outside: The Mental ModelThese two properties sound similar, but they perform two completely different, complementary jobs:
+-------------------------------------------------------------------------+
| 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.clip-pathThe 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:
polygon(x1 y1, x2 y2, ...)You can plot pairs of $X$ and $Y$ percentage coordinates to carve custom geometric polygons:
shape-outsideWhen you float an image and give it border-radius: 50%, paragraph text still wraps in a square:
+-------------------------------------------------------------------------+
| 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!)shape-outside:float: left or float: right). Shapes do not affect text wrapping on non-floated block containers.width and height).shape-margin to provide breathing room between the curved boundary and the surrounding words.shape-outside is not restricted to circles. You can wrap text along diagonal slashes or triangles:
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?
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.clip-path TransitionsBecause clip-path values can be interpolated, you can morph one polygon into another during hover interactions!
| Practice | Bad Approach | Good Approach | Why It Matters |
|---|---|---|---|
| Floating for Shapes | Forgetting float: left/right when applying shape-outside | Always floating the element | shape-outside has zero effect on text wrapping unless the element is floated. |
| Polygon Morphing | Transitioning between a 4-point shape and a 5-point shape | Ensuring identical coordinate counts between states | Mismatched vertex counts break browser interpolation and snap abruptly. |
| Shadows on Clipped Elements | Applying box-shadow on an element with clip-path | Applying filter: drop-shadow(...) on a parent wrapper | clip-path cuts off standard box-shadow pixels outside the boundary. |
| Spacing Around Shapes | Using traditional margin to push text away from shapes | Using shape-margin | shape-margin expands the radial curved boundary rather than an invisible rectangle. |
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.shape-outside requires float: left or float: right.shape-margin: Creates fluid breathing room along the curved shape contour.shape-outside: url(...) with shape-image-threshold: 0.5 wraps around transparent PNGs automatically.clip-path and shape-outside?shape-outside to take effect?clip-path: polygon(...) between two states?shape-outside contour and surrounding wrapped paragraph text?box-shadow fail to appear properly when placed on an element styled with clip-path?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.
shape-outside: circle(50%);, clip-path: circle(50%);, and shape-margin: 20px;.clip-path: polygon(0 0, 100% 0, 85% 100%, 0% 100%);.Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Test your understanding of this lesson with 5 questions. Each question has one correct answer.