clip-path & Masks

clip-path cuts an element into a shape — a circle, a polygon, a slanted edge — hiding everything outside it. Masks go further, using images or gradients to make parts of an element partly or fully transparent. Both make non-rectangular designs possible.

Basic shapes

Try it yourself
Result
FunctionShape
circle(radius at x y)Circle
ellipse(rx ry at x y)Ellipse
inset(top right bottom left round radius)Rectangle cut in from the edges, optionally rounded
polygon(x y, x y, …)Any straight-edged shape
path("…"), shape(…)Curves using SVG-style path commands

Online "clip-path makers" let you drag polygon points and copy the CSS.

Slanted section edges

Try it yourself
Result

Animating clip-path

Try it yourself
Result

Shapes of the same type (and polygons with the same number of points) can be transitioned smoothly — a popular reveal effect.

Masks with gradients

Try it yourself
Result

With mask-image, opaque parts of the mask keep the element visible and transparent parts hide it, with smooth gradations in between — something clip-path's hard edges can't do.

Masks with images and SVG

Try it yourself
Result

Using an SVG icon as a mask lets you fill it with any colour or gradient from CSS — handy for icon systems where icons must match the theme.

clip-path vs mask

clip-pathmask
EdgesHardSoft or hard
Defined byGeometric shapes or pathsImages, gradients, SVG
Click areaClipped areas aren't clickableMasked areas are still clickable
Best forShapes, reveals, section edgesFades, icons, spotlights

Try it yourself

Try it yourself
Result