The four shape functions
clip-path clips an element to a region — everything outside the shape becomes invisible. There are four building blocks:
| Function | Makes | Notes |
|---|---|---|
polygon() | Any multi-point shape | Stars, arrows, diagonals, hexagons |
circle() | Circular clip | circle(50%) = perfect circle |
ellipse() | Oval clip | Independent x/y radii |
inset() | Rectangle | Optional rounded corners |
polygon() is the workhorse — its coordinates are x% y% pairs relative to the element’s box, so polygon(50% 0%, 0% 100%, 100% 100%) is a triangle. This generator lets you drag points and copy the result.
clip-path vs mask
They sound similar but differ in edge quality. clip-path uses geometric coordinates and produces hard, crisp edges — ideal for precise shapes. CSS mask uses an image or gradient as an alpha channel, so it supports soft, gradient, and texture-based edges. Use clip-path for sharp geometric cropping (a diagonal section divider, a hexagon avatar); use mask when you want feathered or image-driven transparency.
Practical uses
- Section dividers — angled or curved boundaries between page sections.
- Reveal animations — animate an
inset()from fully clipped to fully open to wipe content in (mind the point-count rule above). - Shaped media — hexagon/diamond avatars, geometric image crops.
- Hover effects — morph a shape on hover for interactive flair.
Remember that clip-path only affects rendering — the element keeps its original rectangular space in the layout, so surrounding elements don’t reflow around the clipped shape.
Responsiveness and browser support
Using % coordinates makes a clip-path scale with the element automatically, which is what you usually want for responsive layouts; fixed px coordinates stay put and can clip oddly at other sizes. Basic shapes (polygon, circle, ellipse, inset) are supported across all modern browsers — only clip-path: path() (raw SVG path data) has narrower support, so prefer polygon() for the widest compatibility. Older Safari needs the -webkit-clip-path prefix; current versions don’t.