Favorites

path() CSS Function

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

The path() function defines a shape using SVG path data, such as path("M0 0 L100 0 L50 80 Z"), 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 path() CSS function defines a shape using an SVG path data string, the same d attribute syntax used by the SVG <path> element. It is a <basic-shape>, so it can be used with clip-path to cut an element into any outline, with offset-path to move an element along a curved route, and with shape-outside in browsers that support it there.

The path string is made of commands followed by coordinates: M moves to a point, L draws a straight line, H and V draw horizontal and vertical lines, C and S draw cubic Bézier curves, Q and T draw quadratic curves, A draws an arc, and Z closes the shape. Uppercase commands use absolute coordinates and lowercase commands are relative to the previous point. An optional first argument, nonzero or evenodd, sets the fill rule that decides which areas count as inside the shape.

The coordinates are unitless numbers treated as pixels, so a path() shape does not scale with the element. For responsive shapes that can use percentages, calc() and other CSS units, use the newer shape() function, or polygon() for shapes made only of straight lines.

/* Heart-shaped clip */
.heart {
  width: 200px;
  height: 180px;
  clip-path: path("M100,170 C40,120 0,80 0,45 A45,45 0 0 1 100,30 A45,45 0 0 1 200,45 C200,80 160,120 100,170 Z");
}

/* Move an element along a curve */
.dot {
  offset-path: path("M10,80 C40,10 65,10 95,80 S150,150 180,80");
  animation: move 3s ease-in-out infinite alternate;
}

@keyframes move {
  to { offset-distance: 100%; }
}

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: path("M 130 10 L 250 160 L 10 160 Z");
}

Syntax

path() = path( <'fill-rule'>? , <string> )

Values

  • <'fill-rule'>The filling rule for the interior of the path. Possible values are nonzero or evenodd. The default value is nonzero.
  • <string>The string is a data string for defining an SVG path.

Example

<div class="container">
<div class="traveler"></div>
</div>
/* The area where the animation happens */
.container {
width: 100%;
height: 400px;
border: 2px dashed #ccc;
position: relative;
background-color: #f9f9f9;
}

/* The element that will move */
.traveler {
width: 30px;
height: 30px;
background-color: #ff4757;
border-radius: 50%;

/* Define the motion path using the path() function */
/* M = Move to, C = Cubic Bezier Curve */
offset-path: path("M 50 200 C 150 50, 350 350, 450 200");

/* Animate the movement along the path */
animation: moveAlongPath 4s infinite alternate ease-in-out;
}

@keyframes moveAlongPath {
from {
offset-distance: 0%;
}
to {
offset-distance: 100%;
}
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS path() 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.