shape() CSS Function
The shape() function defines a custom shape from drawing commands, like an SVG path but using CSS units, used by clip-path and offset-path.
Description
The shape() CSS function defines a custom shape from a series of drawing commands, similar to an SVG path, but written in CSS syntax. It is a <basic-shape>, used with clip-path to cut elements into any outline and with offset-path to move elements along a route. Its big advantage over path() is that every coordinate can use CSS units, percentages, calc() and custom properties, so shapes scale with the element and can respond to its size.
A shape starts with from and a starting point, followed by comma-separated commands. move to jumps to a new point, line to draws a straight line, and hline and vline draw horizontal and vertical lines. curve to draws a Bézier curve with one or two control points given after with, smooth to continues a curve smoothly, and arc to draws an elliptical arc. close joins the last point back to the start. Using by instead of to makes a point relative to the previous one. An optional fill rule, nonzero or evenodd, can come first.
Because shape() values with the same structure can be interpolated, shapes can be animated smoothly with transitions, for example morphing a wave or a speech bubble.
/* A banner with a pointed right edge that scales with the element */
.banner {
clip-path: shape(from 0 0, line to calc(100% - 30px) 0, line to 100% 50%,
line to calc(100% - 30px) 100%, line to 0 100%, close);
}
/* Wavy bottom edge */
.hero {
clip-path: shape(from 0 0, hline to 100%, vline to 85%,
curve to 0 85% with 75% 105% / 25% 65%, close);
}
Interactive Demo

Syntax
shape() = shape( <'fill-rule'>? from <position> , <shape-command># )
<shape-command> = <move-command> | <line-command> | close | <horizontal-line-command> | <vertical-line-command>
| <curve-command> | <smooth-command> | <arc-command>
Values
- <'fill-rule'>Optional. nonzero (default) or evenodd, deciding which areas are inside the shape.
- from <position>The starting point of the shape, for example from 0 0 or from 50% 0%.
- move [to | by] <position>Starts a new sub-path at a point, without drawing.
- line [to | by] <position>Draws a straight line to the point.
- hline | vline [to | by] <length-percentage>Draws a horizontal or vertical line.
- curve [to | by] <position> with <control-point> [/ <control-point>]?Draws a quadratic (one control point) or cubic (two control points) Bézier curve.
- smooth [to | by] <position> [with <control-point>]?Draws a curve that continues smoothly from the previous one.
- arc [to | by] <position> of <length-percentage>{1,2} [cw | ccw]? [large | small]? [rotate <angle>]?Draws an elliptical arc with the given radius or radii.
- closeDraws a straight line back to the start of the current sub-path.
Example
Browser Support
The following information will show you the current browser support for the CSS shape() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





