CSS clip-path Guide: Polygons, Circles, Animations and Practical Uses
Rectangles are the natural shape of the web, because every element is a box. clip-path lets you break out of the box: cut an image into a hexagon, angle the bottom of a hero section, reveal content with a circular wipe. It’s purely visual, it doesn’t affect layout, and it is supported in every modern browser.
How clipping works
clip-path defines a region. Everything inside the region is visible; everything outside is hidden, including backgrounds, borders, shadows and children. The element still takes up its full rectangular space in the layout.
The basic shape functions
| Function | Example | Draws |
|---|---|---|
inset() | inset(10% 5% round 16px) | A rectangle inset from each edge, optionally rounded |
circle() | circle(40% at 50% 50%) | A circle with a radius and center |
ellipse() | ellipse(50% 30% at center) | An ellipse with two radii |
polygon() | polygon(50% 0, 100% 100%, 0 100%) | Any shape with straight edges |
path() | path('M0 0 L100 0 …') | An SVG path (in pixels, not responsive) |
url(#id) | url(#myClip) | An SVG <clipPath> element |
Newer additions such as shape() bring responsive curves to clip-path, but support is still arriving across browsers. For now, polygon covers most needs.
Polygon coordinates
Each point in polygon() is an x and y coordinate measured from the element’s top-left corner. Percentages are relative to the element’s width (x) and height (y), so the shape scales with the element.
0 0is the top-left corner,100% 0is the top-right,100% 100%is the bottom-right,50% 50%is the center.
A hexagon is six points: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%). Drawing these by hand is fiddly, which is why visual editors exist. The clip-path generator above starts from presets like triangles, stars, arrows and chevrons and lets you drag each point.
Practical uses
Angled section edges. clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%) slants the bottom of a hero section. It’s a common alternative to SVG wave dividers for a sharper, more geometric look.
Image shapes. Hexagonal team photos, diamond thumbnails and circular avatars (although border-radius: 50% is simpler for circles).
Reveal animations. Animating clip-path: circle(0% at 50% 50%) to circle(150% at 50% 50%) creates a circular wipe that reveals an element, popular in page transitions.
Irregular buttons and tabs. Arrow-shaped breadcrumb steps and chevron tabs. Clicks outside the clipped area don’t register, so the clickable area matches the visible shape.
Speech bubbles and badges, using a polygon with a pointer.
Animating clip-path
You can transition between two shapes smoothly, with one rule: both must use the same function and, for polygons, the same number of points. To morph a triangle into a square, give the triangle four points with two of them at the same position. Clip-path animations are generally smooth, but large clipped areas that change every frame can be costly on low-end devices, so test on a phone.
What gets clipped (and what doesn’t)
| Thing | Clipped? | Workaround |
|---|---|---|
| Background and border | Yes | — |
| Children and text | Yes | — |
| box-shadow | Yes | Use filter: drop-shadow() on a parent wrapper |
| outline (focus ring) | Yes | Put the focus style on a parent or use an inner element |
| Pointer events outside the shape | Disabled | This is usually desirable |
| Layout size | Not affected | The element still occupies its full box |
The focus ring issue matters for accessibility: if you clip an interactive element, make sure its keyboard focus indicator is still visible.
clip-path versus mask versus SVG
| Technique | Edges | Soft fades | Best for |
|---|---|---|---|
clip-path | Hard, geometric | No | Shapes, section edges, reveals |
mask-image | Any, from an image or gradient | Yes | Fading edges, complex shapes from PNG/SVG |
border-radius | Rounded rectangles and ellipses | No | Circles, pills, rounded cards |
| Inline SVG | Anything | Yes | Illustrations, icons, complex vector art |
If you need a soft fade, such as an image that fades out at the bottom, use mask-image: linear-gradient(black, transparent). If you need a crisp geometric cut, clip-path is simpler and faster.
Shapes for text flow
clip-path only affects visibility. If you want text to wrap around a shape, combine it with shape-outside on a floated element: shape-outside: circle(50%) makes text flow around a circular image, magazine style.
Things clip-path quietly breaks
- Forgetting about content at the edges. Clipping a card into a shape can cut off text near corners. Add padding or keep text in the middle.
- Using path() for responsive shapes.
path()uses pixel coordinates, so it doesn’t scale. Use polygon with percentages or an SVGclipPathwithclipPathUnits="objectBoundingBox". - Shadows disappearing. Move the shadow to a wrapper with
filter: drop-shadow(), as covered in our box shadow guide.