By default, every HTML element is a rigid rectangle. The clip-path property allows developers to clip an element into geometric shapes — circles, ellipses, triangles, complex multi-point polygons, and SVG paths — without altering the DOM structure.
| Shape Function | Syntax Example | Visual Shape Rendered |
|---|---|---|
circle() |
clip-path: circle(50% at center); |
Clips the element into a perfect circle. |
ellipse() |
clip-path: ellipse(40% 50% at 50% 50%); |
Clips into an oval ellipse with separate X/Y radii. |
inset() |
clip-path: inset(10px round 8px); |
Clips inward from edges with optional rounded corners. |
polygon() |
clip-path: polygon(x1 y1, x2 y2, ...); |
Connects coordinate points to form triangles, stars, or diagonals. |
/* Creates an angled dynamic slant at the bottom of a hero section */
.slanted-hero {
background: linear-gradient(135deg, #d22b2b, #0f172a);
color: #ffffff;
padding: 80px 20px 140px;
/* Top-left (0,0), Top-right (100%,0), Bottom-right (100%,85%), Bottom-left (0,100%) */
clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%);
}
Because clip-path coordinates can be animated smoothly via CSS transitions:
.reveal-card {
clip-path: circle(25px at 100% 0%); /* Tiny circle at top-right */
transition: clip-path 0.5s ease-in-out;
}
.reveal-card:hover {
clip-path: circle(150% at 100% 0%); /* Expands to uncover full card! */
}
Boost your CSS and front-end development proficiency by exploring these closely connected topics:
Understand margins, borders, padding, content and the universal box-sizing fix.
Master 1D alignment, justify-content, align-items, flex-wrap and responsive flow.
Build powerful two-dimensional grid layouts with template areas and fr units.
Eliminate styling conflicts and master selector weights from 0,0,0,1 to !important.