Favorites

shape() CSS Function

shape()
CSS FunctionThis function is supported by all modern browsers.
Updated 21st November 2026

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.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

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

Sunset
Demo Code
HTML Code
<img class="demo-element" src="/css-properties/images/sunset.jpg" alt="Sunset">
CSS Code
.demo-element {
	width: 260px;
	display: block;
	border-radius: 6px;
	clip-path: shape(from 50% 0, line to 100% 100%, line to 0 100%, close);
}

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

<div class="wrap">
<h1>CSS shape() examples</h1>
<div class="grid">
<div class="card">
<div class="box arrow">Arrow</div>
<div class="label">shape(from 0 0, line to calc(100% - 40px) 0, ...)</div>
</div>
<div class="card">
<div class="box wave">Wave</div>
<div class="label">shape(..., curve to 0 75% with 75% 105% / 25% 45%, close)</div>
</div>
<div class="card">
<div class="box bubble">Speech bubble</div>
<div class="label">shape(from 0 0, hline to 100%, vline to 75%, ...)</div>
</div>
</div>
<p class="note">Resize the window: the shapes stretch with the boxes because they use percentages.</p>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
margin: 24px;
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
background: #f5f7fb;
color: #102a43;
}

.wrap {
max-width: 860px;
margin: 0 auto;
}

h1 {
font-size: 20px;
margin: 0 0 16px;
}

.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px;
}

.card {
background: #fff;
border-radius: 12px;
padding: 16px;
box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
font-size: 12px;
color: #486581;
margin-top: 10px;
word-break: break-word;
}

.note {
font-size: 13px;
color: #486581;
margin-top: 14px;
}

/* shape() examples */
.box {
height: 140px;
background: linear-gradient(135deg, #2563eb, #7c3aed);
color: #fff;
display: grid;
place-items: center;
font-weight: 700;
}

.arrow {
clip-path: shape(from 0 0, line to calc(100% - 40px) 0, line to 100% 50%,
line to calc(100% - 40px) 100%, line to 0 100%, close);
}

.wave {
clip-path: shape(from 0 0, hline to 100%, vline to 75%,
curve to 0 75% with 75% 105% / 25% 45%, close);
}

.bubble {
clip-path: shape(from 0 0, hline to 100%, vline to 75%, hline to 40%,
line to 20% 100%, line to 25% 75%, hline to 0, close);
}
Open in editor

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.

This function is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.