CSS offset Property

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

Definition and Usage

The offset property is the Motion Path shorthand. It places a transformable element on a path and controls how far along that path it sits, how it rotates, and which point on the element sticks to the path.

It sets offset-position, offset-path, offset-distance, offset-rotate, and offset-anchor. Animate offset-distance from 0% to 100% to travel the path. It is not inherited, and it creates a stacking context.

Baseline · Formerly motion.

Not deprecated and not experimental. Early drafts used the name motion. Use offset in new code. Widely available since September 2022.

CSS Syntax

syntax.css
offset: <offset-path> <offset-distance> <offset-rotate> / <offset-anchor> | none | initial | inherit;

A common starter is offset: path("M 0 0 L 200 0") 0% auto;. The slash and anchor are optional.

Property Values

Any piece you leave out uses its initial value. The initial path is none, with distance 0 and rotate auto.

ValueDescriptionTry it
path("…")Sets the motion path (offset-path)Try it
50%Distance along the path (offset-distance)Try it
autoRotate to follow the path direction (offset-rotate)Try it
0degKeep a fixed angle instead of following the pathTry it
/ centerAnchor point after a slash (offset-anchor)Try it
noneNo path. The element stays in normal layoutTry it
initialResets each longhand to its initial valueTry it
inheritInherits this shorthand from the parent elementTry it

How to Use offset

Pick a path, place the element on it, then animate the distance.

  1. Choose a path with path(), circle(), or another offset-path value.
  2. Set offset (or the longhands) on the moving element. It is not inherited.
  3. Animate offset-distance from 0% to 100% with @keyframes.
  4. Add auto rotate when the element should face along the path.
PieceRequired?Role
A pathYesWithout offset-path, distance has nowhere to travel
DistanceFor motionAnimate 0% → 100% to move along the path
RotateNoauto follows the tangent; an angle stays fixed
AnchorNoWhich point on the element sits on the path

Live Preview

A marker sits on a straight path. Change offset-distance to see where it stops along that path.

Path is fixed. Distance is the percentage of that path from start to end.

Path

offset-distance: 0%

CSS Examples

Each snippet adds only what offset needs: a path, a distance, and an optional rotate. Use Try It Yourself for a live editor.

Example 1 — Line Path

Place a box on a straight path and animate the distance from start to end.

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

<div></div>
Try It Yourself

How It Works

  1. Set the path in the shorthand. path("M 20 80 L 280 80") is a horizontal line from left to right.
  2. Start at 0%. That is the distance along the path. 0deg keeps the box upright.
  3. Animate the distance. The keyframes move offset-distance to 100%, so the box travels the full line.
  4. Repeat forever. infinite and linear make a steady loop for study.

Example 2 — Auto Rotate on a Circle

Orbit a box and let auto rotate it to follow the path direction.

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

<div></div>
Try It Yourself

How It Works

  1. Use a closed path. The SVG arc commands draw a circle for the marker to follow.
  2. Set rotate to auto. The box turns so it faces along the tangent of the path.
  3. Animate distance again. 0% to 100% completes one full orbit.
  4. Compare with 0deg. A fixed angle keeps the box upright while it still travels the circle.

Example 3 — Curve with Fixed Angle

Follow a quadratic curve while keeping the box upright with 0deg.

CSS
<style>
  @keyframes wave {
    to { offset-distance: 100%; }
  }
  div {
    width: 24px;
    height: 24px;
    background: #2563eb;
    offset: path("M 20 100 Q 100 20 180 100 T 340 100") 0% 0deg;
    animation: wave 4s ease-in-out infinite alternate;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Draw a curve. Q and T commands create a wave path without SVG markup in the HTML.
  2. Keep rotate at 0deg. The box moves along the wave but does not tip with the curve.
  3. Use alternate. The animation goes to the end, then back to the start.
  4. Ease both ends. ease-in-out softens the turnaround so the motion is easier to watch.

Edge Cases & Pitfalls

If the element does not move, one of these is usually why.

path

No path, no travel

The initial offset-path is none. Without a path, changing distance does nothing visible.

motion

Distance must change

A fixed path alone only parks the element. Animate offset-distance (or set different distances) to see movement.

inset

Not top / left

offset is a motion-path transform. It does not replace inset positioning for normal document layout.

slash

Anchor needs a slash

Write the anchor after /, such as offset: path("…") 50% auto / center. Without the slash, the position values are read as other parts of the shorthand.

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 is a browser CSS property for Motion Path. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available since 2022

offset

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 Widely supported

Bottom line: Safe for modern motion-path demos. Individual longhands landed at slightly different times; the shorthand is Baseline since 2022. Provide a non-animated fallback when older browsers matter.

Key Takeaways

  • Role: Motion Path shorthand for path, distance, rotate, and anchor.
  • Travel: animate offset-distance from 0% to 100%.
  • Rotate: auto follows the path; an angle stays fixed.
  • Name: early drafts said motion. Use offset today. Not inherited.

One line: set a path with offset, then animate the distance to make the element travel.

Frequently Asked Questions

offset is the Motion Path shorthand. It places an element on a path and controls how far along that path it sits, how it rotates, and which point on the element anchors to the path.
No. Inset properties move positioned boxes in normal layout. offset moves an element along a defined path such as path(), circle(), or ray().
It sets offset-position, offset-path, offset-distance, offset-rotate, and offset-anchor. A slash separates the optional anchor value.
Usually yes. The common pattern is a fixed path plus an animation that changes offset-distance from 0% to 100%.
Yes. Early drafts used the name motion. Modern browsers use offset. Prefer offset in new code.
It is Baseline and widely available since September 2022: Chrome 55+, Firefox 72+, Safari 15.4+, Edge 79+, and Opera 42+. Internet Explorer has no support. It is a browser CSS property, not a Node.js feature.

Next: offset-anchor

Learn which point on the element aligns to the motion path.

offset-anchor 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