CSS offset-path Property

Beginner
7 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The offset-path property defines the route an element follows. That route can be a custom SVG-style path(), a basic shape such as circle(), or none.

Pair it with offset-distance to place or animate the element along the path. offset-rotate and offset-anchor control facing and which point sticks to the path. The initial value is none. It is not inherited, and it creates a stacking context.

Baseline · Formerly motion-path.

Not deprecated. Early drafts used motion-path. Use offset-path in new code. path() and circle() are the safest starters; ray() and some newer shapes still vary by browser.

CSS Syntax

syntax.css
offset-path: none | path("…") | circle() | polygon() | ray() | initial | inherit;

Property Values

ValueDescriptionTry it
noneDefault. No path. The element stays in normal layoutTry it
path("…")An SVG path string. Best for custom lines and curvesTry it
circle()A circular route. Easy first orbit for beginnersTry it
polygon()A closed shape made of straight edgesTry it
ray()A ray from a point at an angle. Support still variesTry it
initialSets this property to its default value, noneTry it
inheritInherits this property from the parent elementTry it

How to Use offset-path

Pick a path shape, then move along it with distance.

  1. Choose a path value such as path() or circle().
  2. Set offset-path on the moving element. It is not inherited.
  3. Set or animate offset-distance from 0% to 100%.
  4. Add rotate or anchor only when you need facing or a different contact point.
PieceRequired?Role
Path valueYesThe route: path(), circle(), polygon(), and others
offset-distanceFor motionProgress along that route
@keyframesFor loopsAnimate distance over time
Rotate / anchorNoFacing and which point sticks to the path

Live Preview

The marker travels the selected path. Change offset-path and watch the route change.

Distance animates from 0% to 100%. Switching the path changes the route, not the animation idea.

Path

offset-path: path("M 24 88 L 280 88")

CSS Examples

Each snippet adds only what offset-path needs: a path and animated distance. Use Try It Yourself for a live editor.

Example 1 — Custom path()

Draw a straight SVG path and travel it end to end.

CSS
<style>
  @keyframes travel {
    to { offset-distance: 100%; }
  }
  div {
    width: 24px;
    height: 24px;
    background: #2563eb;
    offset-path: path("M 20 80 L 280 80");
    offset-rotate: 0deg;
    animation: travel 4s linear infinite;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Write an SVG path string. M moves to the start. L draws a line to the end.
  2. Assign it with path(). That string becomes the motion route.
  3. Animate distance. Keyframes push offset-distance to 100% so the box travels the line.
  4. Keep rotate fixed. 0deg makes the demo about the path shape, not tipping.

Example 2 — circle()

Orbit a box on a circular path — a simple first shape for beginners.

CSS
<style>
  @keyframes orbit {
    to { offset-distance: 100%; }
  }
  div {
    width: 24px;
    height: 24px;
    background: #2563eb;
    offset-path: circle(50px at 140px 80px);
    offset-rotate: auto;
    animation: orbit 5s linear infinite;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Use a basic shape. circle(50px at 140px 80px) is a 50px radius centered in the stage.
  2. The route is the outline. The element follows the circle’s edge, not a filled disk.
  3. Set rotate to auto. The box turns to face along the orbit.
  4. Animate a full lap. 0% to 100% completes one trip around the circle.

Example 3 — polygon()

Follow the edges of a rectangle made with polygon().

CSS
<style>
  @keyframes lap {
    to { offset-distance: 100%; }
  }
  div {
    width: 24px;
    height: 24px;
    background: #2563eb;
    offset-path: polygon(20% 20%, 80% 20%, 80% 80%, 20% 80%);
    offset-rotate: 0deg;
    animation: lap 5s linear infinite;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. List the corners. Four percentage points make a rectangle inside the containing box.
  2. The path is the outline. The marker walks each edge in order, then closes the shape.
  3. Percentages are relative to the containing block. Resize the stage and the route scales with it.
  4. Same distance trick. Animating to 100% completes one full lap of the polygon.

Edge Cases & Pitfalls

If the element does not follow a route, one of these is usually why.

none

Default is none

Without a path value, distance has nowhere to travel. Set path(), circle(), or another shape first.

distance

Path alone parks at the start

Initial offset-distance is 0. Animate or change distance to move along the route.

name

Not motion-path anymore

Old drafts used motion-path. Use offset-path in modern CSS. Some demos still show both for legacy.

ray

ray() support varies

Stick to path() and circle() for widest support. Treat ray() and newer shapes as progressive enhancement.

a11y

Respect reduced motion

Looping path animations can distract. Prefer a static distance, or pause motion, when prefers-reduced-motion is reduce.

Browser Support

offset-path is a browser CSS property for Motion Path. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available since 2022

offset-path

Chrome 55+, Firefox 72+, Safari 15.4+, Edge 79+, Opera 42+. Internet Explorer has no native support.

94% Modern browser support
Google Chrome 55+ · Desktop & Mobile
Full support
Mozilla Firefox 72+ · Desktop & Mobile
Full support
Apple Safari 15.4+ · macOS & iOS
Full support
Microsoft Edge 79+ · Chromium
Full support
Opera 42+ · Modern versions
Full support
Samsung Internet 6.2+ · Android
Full support
Internet Explorer No support
None
offset-path Widely supported

Bottom line: Safe for modern demos with path() and circle(). Some values such as ray() and newer basic shapes still have uneven support — check before relying on them.

Key Takeaways

  • Role: define the route the element follows.
  • Starters: path() for custom routes, circle() for orbits.
  • Motion: animate offset-distance; the path stays fixed.
  • Default: none. Formerly motion-path. Not inherited.

One line: offset-path draws the route; offset-distance walks it.

Frequently Asked Questions

It defines the route an element follows. Pair it with offset-distance to place or animate the element along that route.
none. With none, there is no motion path and the element stays in normal layout.
Yes. Early drafts used motion-path. Modern browsers use offset-path. Prefer offset-path in new code.
Start with path() for a custom line or curve, or circle() for a simple orbit. Animate offset-distance from 0% to 100% to travel the path.
A path alone parks the element at distance 0. Change or animate offset-distance to move along the path.
It is Baseline and widely available since March 2022: Chrome 55+, Firefox 72+, Safari 15.4+, and Edge 79+. Some values such as ray() have uneven support. It is a browser CSS property, not a Node.js feature.

Next: offset-rotate

Learn how to turn the element as it follows the path.

offset-rotate tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful