CSS Portal

CSS offset-path Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The offset-path property defines a geometric path that an element can follow for offset positioning, serving as the foundation of CSS motion-path behavior. It tells the browser which curve, line or shape should be used to compute the element’s visual position along that route; that computed position is then applied to the element during painting so the element appears to travel along the path. Think of offset-path as the track or route, while other offset-related properties determine where on that track an element sits and how it is oriented.

In practice the property is used in tandem with the properties that control the element’s progress along and orientation relative to the path: offset-distance controls how far along the path the element is placed, and offset-rotate controls its rotation relative to the path’s tangent. Because the path-based positioning is applied at paint/compositing time, it normally does not change the document flow or the layout of other elements; it is a visual transformation layered on top of the element’s laid-out box. For that reason it often composes similarly to other visual transforms and can interact with, or be combined with, a regular transform.

Common uses for offset-path include creating intricate motion effects, moving UI elements along non-linear tracks, or animating complex entrance and exit behaviors. It integrates naturally with CSS animation and transition systems — you typically animate the property that represents progress along the path (for example animation keyframes animating offset-distance, or a transition on the same) so the element moves smoothly along the specified route. From a performance and accessibility standpoint, it’s best used where the motion is primarily visual: combining path motion with composited transforms and limiting layout-changing animations helps preserve rendering performance and predictable keyboard/assistive technology behavior.

Definition

Initial value
none
Applies to
transformable elements
Inherited
no
Computed value
as specified
Animatable
by computed value type
JavaScript syntax
object.style.offsetPath

Interactive Demo

Syntax

offset-path: none | path() | ray() | url() | <basic-shape>

Values

  • noneSpecifies that the element does not follow any offset path. The none value is equivalent to the element not having any offset transform.
  • path()Specify a path in SVG syntax.
  • ray()Specify a path with the CSS ray() function.
  • url()Specify a path by using the URL to an SVG file.
  • <basic-shape>Specify a path by defining a basic shape using CSS functions like inset(), circle(), ellipse() or polygon().

Example

<div class='stage'>
<svg class='guide' viewBox='0 0 500 300' preserveAspectRatio='none'>
<path id='motionPath' d='M40 200 C150 0 350 400 460 200' />
</svg>
<div class='ball' aria-hidden='true'></div>
</div>
/* Layout and visuals */
* {
  box-sizing: border-box;
}
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: #f6f7fb;
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  width: 500px;
  height: 300px;
  position: relative;
}

.guide {
  position: absolute;
  inset: 0;
  overflow: visible;
}

.guide path {
  stroke: #e6e9ef;
  stroke-width: 4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ball {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #ff8a8a, #ff4b4b);
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);

  /* Motion path properties */
  offset-path: path('M40 200 C150 0 350 400 460 200');
  -webkit-offset-path: path('M40 200 C150 0 350 400 460 200');
  offset-rotate: auto;
  -webkit-offset-rotate: auto;
  offset-distance: 0%;
  -webkit-offset-distance: 0%;

  animation: travel 4s ease-in-out infinite;
}

@keyframes travel {
  0% {
    offset-distance: 0%;
    -webkit-offset-distance: 0%;
  }
  50% {
    offset-distance: 100%;
    -webkit-offset-distance: 100%;
  }
  100% {
    offset-distance: 0%;
    -webkit-offset-distance: 0%;
  }
}

Browser Support

The following information will show you the current browser support for the CSS offset-path property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property 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
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!