CSS propertyEffects

clip-path

Clips an element to a chosen shape: a circle, ellipse, polygon and more.

Initial value
none
Inherited
No
Animatable
yes, as a shape with the same number of points
Applies to
all elements
JavaScript
element.style.clipPath = "circle(50%)"
On this page

Example

#
CSS
.hero {
  clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%);
}
Preview

Definition and usage

#

The clip-path property makes only the part of an element inside the given shape visible. The rest is invisible and doesn’t respond to clicks. You create shapes with the circle(), ellipse(), inset() and polygon() functions.

polygon() takes a list of points in percentages, which lets you create triangles, arrows, cut corners and slanted section edges.

Shapes can be animated if they have the same number of points. This gives striking image reveals and transitions between sections.

Syntax

#
Syntax
clip-path: none | circle(…) | ellipse(…) | inset(…) | polygon(…) | path(…);

Values

#

Values in practice

#

none

The whole element is visible.
.demo { clip-path: none; }

circle(40%)

A circle with a 40% radius at the centre of the element.
.demo { clip-path: circle(40%); }

inset(10% round 16px)

A rectangle inset from the edges, with rounded corners.
.demo { clip-path: inset(10% round 16px); }

polygon(50% 0, 100% 100%, 0 100%)

A triangle with its apex at the top.
.demo { clip-path: polygon(50% 0, 100% 100%, 0 100%); }

polygon(0 0, 100% 0, 100% 80%, 0 100%)

A slanted bottom edge, popular in page sections.
.demo { clip-path: polygon(0 0, 100% 0, 100% 80%, 0 100%); }

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Polygon shapes are easiest to prepare in online generators, then paste the finished polygon().
  • The clipped part not only disappears but also stops responding to the mouse. Be careful not to cut off a clickable area.

Related entries

#

Practise it in lessons

#

Spotted a mistake or missing an example? Write to us.