Clipping: clip-path With inset(), circle(), polygon(), path() and shape()
Cutting elements into shapes with clip-path: inset(), xywh(), rect(), circle(), ellipse() and polygon(), responsive curves with shape() versus path(), reference boxes, SVG clipPath, how clipping affects clicks, layout and outlines, and animation.
kvi5hnuCode Sprout team member7 min readOn this page
clip-path draws only the part of an element inside a shape; everything outside is cut away. It's used for diagonal section edges, circular avatars, reveal animations, and decorative shapes, without extra images.
.avatar { clip-path: circle(50%); }
.section { clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%); } /* slanted bottom edge */
Clipping is all or nothing: a pixel is either drawn or not. For soft edges and gradual transparency, use a mask (article 101).
Shape functions

Article 55 introduced these shapes for shape-outside; clip-path accepts the same ones:
| Function | Example | Notes |
|---|---|---|
inset() | inset(10% 5% round 12px) | offsets from the top, right, bottom and left edges, like margin; round adds corner radii |
xywh() | xywh(0 0 50% 100% round 8px) | position and size |
rect() | rect(0 auto 50% 0) | top, right, bottom and left edges, measured from the top and left; auto means the far edge |
circle() | circle(40% at 30% 50%) | radius, then the center after at; closest-side (default) and farthest-side work as radii |
ellipse() | ellipse(50% 35% at center) | two radii |
polygon() | polygon(50% 0, 100% 100%, 0 100%) | x y points, comma-separated; optional evenodd fill rule first |
path() | path("M0 0 H200 L100 100 Z") | an SVG path string, in pixels |
shape() | shape(from 0% 100%, curve to 100% 100% with 50% 0%, close) | a path with percentages, so it scales |
Tested in Chrome: xywh(10px 10px 50% 50% round 8px) computed to inset(10px calc(50% - 10px) calc(50% - 10px) 10px round 8px), and rect(10px auto 50% 0) to inset(10px 0% 50% 0px). So all three rectangle functions are ways of writing an inset().
A percentage radius in circle() is relative to the box's normalized diagonal, √((w² + h²) / 2), so circle(50%) on a rectangle is a circle, not an ellipse: in a wide box it's cut off at the top and bottom. For a circle that always fits, use circle(closest-side), the default.
path() and shape()
path() takes an SVG path string, which can draw any curve, but its coordinates are pixels: the shape doesn't scale with the element. shape() uses CSS syntax, accepts percentages, calc() and custom properties, and so works for responsive elements:
.wave {
clip-path: shape(
from 0% 0%,
line to 100% 0%,
line to 100% 80%,
curve to 0% 80% with 50% 110%, /* a curve down to the left side */
close
);
}
Commands include move to, line to, hline to, vline to, curve to … with … (quadratic with one control point, cubic with two), smooth to, arc to … of <radius>, and close. by instead of to makes a point relative to the previous one. Tested in Chrome: with shape(from 0% 100%, curve to 100% 100% with 50% 0%, close) on a 200 × 100px box, a click near the top center missed the element, and one in the middle hit it.
shape() works in Chrome 135, Safari 18.4 and Firefox 148.
SVG <clipPath>
clip-path: url(#id) uses a <clipPath> element from an inline SVG, which can combine several shapes or text. To make it scale with the element, set clipPathUnits="objectBoundingBox" and use coordinates from 0 to 1:
<svg width="0" height="0" aria-hidden="true">
<clipPath id="blob" clipPathUnits="objectBoundingBox">
<path d="M0.5 0 C0.9 0 1 0.3 1 0.55 C1 0.9 0.7 1 0.45 1 C0.15 1 0 0.75 0 0.5 C0 0.2 0.2 0 0.5 0 Z"/>
</clipPath>
</svg>
.photo { clip-path: url(#blob); }
With shape() now in all major browsers, most responsive shapes no longer need SVG.

The dashed outline never changes: clipping hides parts of the element, but its box, and the space it takes in the layout, stay the same.
Reference boxes
By default, percentages and the shape refer to the border box. A box keyword after the shape changes that, and a box keyword alone clips to that box:
.card { clip-path: inset(0 round 16px) padding-box; } /* rounded at the padding edge */
.frame { clip-path: content-box; } /* hide padding and border */
The boxes are margin-box, border-box (default), padding-box and content-box, plus fill-box, stroke-box and view-box for SVG elements.
What clipping affects
- Painting: only the inside is drawn, including the element's shadows and outlines. A
box-shadowor focus outline outside the shape is cut off. Put the shadow on a wrapper withfilter: drop-shadow()to follow the clipped shape. - Clicks: the clipped-away area doesn't receive pointer events. Tested in Chrome: on a 200 × 100px element with
clip-path: circle(30px),elementFromPoint()found the element at its center and nothing at its corner. - Layout: unaffected. The element still takes its full box, and the text around it doesn't wrap to the shape. For that, use
shape-outsidetoo (article 55). - Stacking: any
clip-pathother thannonecreates a stacking context, and is a backdrop root (article 98).
Because focus outlines are clipped, clipped interactive elements need a focus indicator inside the shape, such as a color change or an inner box-shadow: inset, or a focus ring on a wrapper.
Animating clip paths
clip-path can be transitioned and animated between shapes of the same kind. Tested in Chrome, 40% of the way through an animation:
- Between two three-point polygons, the third point had moved from 50% to 70%, smoothly.
- Between
circle(10%)andcircle(50%), the radius was 26%. - Between a three-point and a four-point polygon, or between
circle()andinset(), there was no interpolation: the value was still the first shape.
So keep the same function and number of points, adding duplicate points where needed:
.reveal { clip-path: circle(0% at 50% 50%); transition: clip-path 0.6s ease; }
.reveal.open { clip-path: circle(75% at 50% 50%); }
.wipe { clip-path: inset(0 100% 0 0); animation: wipe 0.8s forwards; }
@keyframes wipe { to { clip-path: inset(0 0 0 0); } }
Respect prefers-reduced-motion for large reveal animations.
body { font: 0.8rem system-ui, sans-serif; margin: 1rem; }
.stage { margin: 0.5rem 0; padding: 0.4rem; border: 2px dashed #d8cfc0; inline-size: fit-content; }
.clipped {
inline-size: 14rem; block-size: 7rem; display: grid; place-items: center;
font: 800 1.4rem system-ui, sans-serif; color: white;
background: linear-gradient(135deg, #8a3b12, #f4c95d);
clip-path: var(--shape, circle(40% at 50% 50%));
transition: clip-path 0.5s ease;
}
.reveal {
margin-top: 0.5rem; padding: 1rem; border-radius: 8px; color: white; font-weight: 700;
background: #1d3557;
clip-path: circle(0% at 0% 50%);
transition: clip-path 0.7s ease;
}
.reveal.open { clip-path: circle(150% at 0% 50%); }
button { font: inherit; padding: 0.3rem 0.7rem; }
@media (prefers-reduced-motion: reduce) { .clipped, .reveal { transition: none; } }
The dashed outline shows the element's full box, which stays the same whatever the shape. Switching between the pentagon and the slanted edge animates smoothly, because both are polygon() with five points (the slanted edge has an extra point in the middle of its bottom edge). Switching between different functions, like circle and inset, jumps.
What's current
- Basic shapes,
path()and box keywords: all browsers. xywh()andrect(): all browsers.shape(): Chrome 135, Safari 18.4, Firefox 148.
Common questions
Why is my circle(50%) cut off on a rectangle?
Percentages use the normalized diagonal. Use circle(closest-side) or circle() for the largest circle that fits.
Why did my box shadow disappear?
It's outside the clip. Put filter: drop-shadow() on a wrapper element.
Why doesn't my clip-path animate?
The two shapes are different functions or have different numbers of points.
Does clip-path change layout?
No. The element keeps its full size; only painting and hit testing change.
Summary
clip-pathdraws only the inside of a shape; clipped areas don't receive clicks, but layout is unchanged.inset(),xywh()andrect()describe rectangles;circle(),ellipse()andpolygon()the rest;shape()makes responsive curves,path()pixel-based ones.- Shapes refer to the border box unless a box keyword is given.
- Shadows and focus outlines outside the shape are clipped.
- Animate between shapes of the same function with the same number of points.
Practice questions
Write a clip-path that cuts a diagonal bottom edge on a hero section, from full height on the left to 80% on the right.
Answer
.hero { clip-path: polygon(0 0, 100% 0, 100% 80%, 0 100%); }
Why might a click near the corner of a clip-path: circle(50%) button do nothing?
Answer
Clipped-away areas don't receive pointer events, so clicks outside the circle go to whatever is behind the button.
Why doesn't this transition animate smoothly?
.shape { clip-path: polygon(50% 0, 100% 100%, 0 100%); transition: clip-path 0.4s; }
.shape:hover { clip-path: inset(0); }
Answer
polygon() and inset() are different functions, so they can't be interpolated. Use a four-point polygon in both states, for example polygon(50% 0, 50% 0, 100% 100%, 0 100%) and polygon(0 0, 100% 0, 100% 100%, 0 100%).
What's the advantage of shape() over path() for a curved section divider?
Answer
shape() accepts percentages, so the curve scales with the element's width and height; path() uses fixed pixel coordinates.
Previous: Blend Modes: background-blend-mode, mix-blend-mode and isolation
Next: Masking: mask-image, Luminance and Alpha Masks, and the mask Properties

More in CSS Course
Quiz: CSS Delicate Details
Twenty-five questions on the edge cases that surprise experienced developers: invalid custom properties, shorthands that reset values, layer order with !important, containing blocks, margin collapsing, specificity of :is() and :where(), intrinsic minimum sizes, and more, each checked in Chrome.
Quiz: CSS Interview Questions
Thirty front-end interview questions: cascade, specificity and layers, box model and margin collapsing, stacking contexts, positioning, flexbox and grid, responsive design, custom properties, performance, accessibility, modern selectors and architecture.
Quiz: CSS Course Final Exam
Thirty questions across the whole CSS course: syntax and error handling, selectors, the cascade and layers, values and units, color, the box model, backgrounds, positioning, flexbox, grid, responsive design, typography, generated content, effects, transforms, motion and architecture.
Quiz: CSS Architecture, Tooling and Debugging (CSS Part 17)
Twenty questions on modular CSS and BEM, layering a stylesheet, design tokens and theming, pattern libraries and safe refactoring, preprocessors and build tools, the at-rules reference, and debugging common CSS problems.
Discussion
Sign in to ask a question or share what you learned.