CSS Motion Path Animation with offset-path

Motion path animation without JavaScript

Animating an element along a curve used to mean GSAP's motionPath plugin or manually calculating x/y coordinates in a JS loop. CSS offset-path lets you define the path, then animate offset-distance from 0% to 100%.

Old way GSAP motionPath
<!-- SVG in HTML --><svg><path id="track" d="M 0 0 C 150 -100 300 100 450 0"/></svg><div class="ball"></div>// gsap + motionPath plugin requiredgsap.to('.ball', {  duration: 2,  ease: 'none',  motionPath: { path: '#track', autoRotate: true }});
Modern
Pure CSS
@keyframes along-path   {  from   {    offset-distance: 0%;  }  to     {    offset-distance: 100%;  }}.ball   {  offset-path: path("M 0 0 C 150 -100 300 100 450 0");  offset-distance: 0%;  offset-rotate: auto;  animation: along-path 2s linear infinite;}
Widely available Since 2022 95% global usage

This feature is well established and works across many devices and browser versions. It has been available across browsers since 2022.

Safe to use without fallbacks.

46+
72+
16+
79+
ball follows a bezier curve — no JavaScript
offset-path: path("M 0 0 C 150 -100 300 100 450 0");
offset-distance: 0% → 100%; offset-rotate: auto;

No library needed

Drop GSAP and the motionPath plugin. The path lives in CSS, the animation runs on the compositor.

Auto-rotation built in

offset-rotate: auto tilts the element to follow the curve. No angle math required.

Any path shape

Use any SVG path string: straight lines, bezier curves, circles. The element follows it exactly.

Key Change
CSS path
offset-path + offset-distance
Old Approach
GSAP / JS
motionPath plugin or manual coords
Modern Approach
offset-path
Pure CSS, no dependencies

How it works

offset-path defines the route an element travels. You give it an SVG path string, the same format used in a <path d="..."> element. The element gets placed at position 0% by default.

offset-distance is a percentage that moves the element along that path. Animate it from 0% to 100% and the element travels the full route. Combine with offset-rotate: auto and the element also rotates to stay aligned with the curve direction.

You can use circle(), ellipse(), or ray() as the path value instead of a full SVG path string if your route is a simple shape.

ESC