← All guides

Design · 7 min read

CSS Shapes with clip-path

The clip-path property cuts an element to a shape: everything outside the shape becomes invisible, and the element no longer responds to clicks there. It turns rectangular boxes into circles, slanted section dividers, hexagonal avatars, arrow-shaped buttons and diagonal hero images without extra images or wrapper elements — and the shapes can be animated.

This guide covers the basic shape functions, polygons, path() and shape(), using SVG clip paths, animating between shapes, and what clipping does and does not affect.

Try it yourself with the related tool.

Build a clip-path →

Advertisement

Basic shapes

clip-path: circle(50%) clips to a circle with a radius of half the element; circle(40% at 30% 50%) sets the radius and centre. ellipse(50% 35%) takes two radii. inset(10px 20px round 12px) clips to a rectangle inset from each edge, with optional rounded corners — useful for reveal effects. Percentages are relative to the element's reference box, which by default is the border box and can be changed with a keyword such as content-box.

Polygons

polygon() takes a list of points as x and y coordinates, usually in percentages so the shape scales with the element. polygon(50% 0%, 100% 100%, 0% 100%) is a triangle. polygon(0 0, 100% 0, 100% 85%, 0 100%) cuts a slanted bottom edge, a popular way to make sections flow into each other. Hexagons, arrows, chevrons, stars and speech-bubble tails are all simple polygons. Points are joined with straight lines in order, and the shape closes automatically.

Curves with path() and shape()

For curved outlines, path() accepts SVG path data such as path("M0 0 H200 V150 Q100 200 0 150 Z"). Its weakness is that coordinates are in pixels, so the shape does not scale with the element. The newer shape() function, now reaching all major browsers, uses CSS units and percentages with readable commands such as curve to and line to, combining the flexibility of paths with responsive sizing. Until it is everywhere, provide a polygon fallback or use an SVG clip path.

SVG clip paths

An inline SVG <clipPath> with clipPathUnits="objectBoundingBox" uses coordinates from 0 to 1 relative to the element, so it scales responsively and can contain any curves, text or combined shapes. Reference it with clip-path: url(#my-clip). This is the most flexible option and works in all browsers, at the cost of extra markup.

Animating shapes

Clip paths can be transitioned and animated when both states use the same function with the same number of points: a polygon with four points can morph into another four-point polygon, and circle(0%) can grow to circle(150%) for a circular reveal. To morph between shapes with different point counts, repeat points in the simpler shape so the counts match. Hover reveals with inset() — from fully inset to inset(0) — make smooth image wipes.

What clipping affects

Clipped areas are not drawn and do not receive pointer events, so a clipped button is only clickable inside its visible shape. Clipping does not change layout: the element still takes up its full rectangular box, and neighbouring content does not flow around the shape. For text that wraps around a circle or polygon, use shape-outside on a floated element, which accepts the same shape functions. Box shadows and outlines are clipped too, so to give a clipped element a shadow, apply filter: drop-shadow() to a wrapper.

Browser support and fallbacks

Basic shapes and polygons are supported in every current browser, unprefixed. Older Safari versions needed -webkit-clip-path, which is harmless to include. Because an unsupported clip path simply leaves the element rectangular, clipping is a safe progressive enhancement: design so the unclipped version still looks acceptable, and use @supports (clip-path: polygon(0 0)) when other styles depend on the shape.

Clip-path versus masks

Clipping is binary: each pixel is either fully visible or hidden, with hard edges. The mask-image property uses an image or gradient's alpha channel, allowing soft, partially transparent edges — fading the bottom of an image into the background, for example. Use clip-path for crisp geometric shapes and mask for soft or textured edges.

Related guides