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%)"
Example
#.hero {
clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%);
}<section style="padding: 28px 20px 44px; background: linear-gradient(135deg, #7c3aed, #0ea5e9); clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%);">
<h2 style="margin: 0">A section with a slanted edge</h2>
</section>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
#clip-path: none | circle(…) | ellipse(…) | inset(…) | polygon(…) | path(…);Values
#- The whole element is visible.
- A circle with a 40% radius at the centre of the element.
- A rectangle inset from the edges, with rounded corners.
polygon(50% 0, 100% 100%, 0 100%)
triangle
A triangle with its apex at the top.polygon(0 0, 100% 0, 100% 80%, 0 100%)
slant
A slanted bottom edge, popular in page sections.
Values in practice
#none
.demo { clip-path: none; }circle(40%)
.demo { clip-path: circle(40%); }inset(10% round 16px)
.demo { clip-path: inset(10% round 16px); }polygon(50% 0, 100% 100%, 0 100%)
.demo { clip-path: polygon(50% 0, 100% 100%, 0 100%); }polygon(0 0, 100% 0, 100% 80%, 0 100%)
.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.