Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Filters, Masks and Shapes

The clip-path property

Reference for the CSS clip-path property: clip an element to a circle, ellipse, inset rectangle, polygon or path, with live examples and usage notes.

The clip-path property cuts an element to a shape. Anything outside the shape is not painted and does not receive pointer events. You can use basic shapes such as circle() and polygon(), a reference to an SVG <clipPath>, or a box keyword.

Clipping is hard-edged: a point is either inside or outside. For soft, semi-transparent edges use a mask instead.

CSS
.avatar {
  clip-path: circle(50%);
}

Try it

Basic shapes
Hover reveal with a transition

Shapes with the same function and the same number of points can be animated, so the circle grows smoothly. Note that the hover target is only the visible part, because clipped areas do not receive pointer events.

Syntax

CSS
clip-path: none
         | <basic-shape> || <geometry-box>
         | url(#clip-id)

/* <basic-shape>: inset() | circle() | ellipse() | polygon() | path()
                  (and the newer rect(), xywh() and shape()) */
/* <geometry-box>: margin-box | border-box | padding-box | content-box
                  | fill-box | stroke-box | view-box */
  • Initial value: none
  • Applies to: all elements; in SVG, all graphics and container elements
  • Inherited: no
  • Animatable: yes, between shapes of the same type (and same number of points for polygon())
  • Computed value: none, a computed basic shape, plus the box if given, or the URL made absolute

Values

Value Description
none No clipping.
inset(top right bottom left round radius) A rectangle inset from the reference box; round adds corner radii.
circle(radius at position) A circle. The radius can be a length, a percentage or closest-side / farthest-side.
ellipse(rx ry at position) An ellipse with two radii.
polygon(x y, x y, ...) Any straight-sided shape from a list of points; an optional first nonzero or evenodd sets the fill rule.
path("M ...") A shape from SVG path syntax, in pixels. It does not scale with the element.
url(#id) An SVG <clipPath> element, which can scale with the element via clipPathUnits="objectBoundingBox".
<geometry-box> The box that percentages and the shape refer to. Default border-box. Alone, it clips to that box's edge.

The shape functions are covered in circle() and basic shapes.

Usage notes

  • Clipped parts are inert. They cannot be clicked, hovered or focused by pointer, but keyboard focus still works, so a clipped link remains reachable.
  • Shadows and outlines are clipped too. A box-shadow or outline outside the shape disappears; apply filter: drop-shadow() to a wrapper element to get a shadow that follows the shape.
  • Creates a stacking context when its value is not none.
  • Percentages refer to the reference box, so circle(50%) is relative to the box size (for circles, to sqrt(wยฒ + hยฒ) / sqrt(2), which makes 50% of a square exactly fit).
  • path() does not scale. For responsive shapes prefer polygon() with percentages, or an SVG <clipPath> with objectBoundingBox units.
  • Accessibility. Clipping hides pixels only; the content stays in the accessibility tree. Do not use it to hide information visually if it must also be hidden from screen readers.
  • Debugging. Temporarily set a bright background to see what the shape really covers.

Browser support

The basic shapes and url() references work in all current major browsers. Newer shape functions such as rect(), xywh() and shape() arrived later, so check a compatibility table before using them.