CSS offset-distance Property

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

Definition and Usage

The offset-distance property sets how far an element sits along an offset-path. 0% is the start of the path. 100% is the end.

The initial value is 0. Percentages refer to the total path length. Animate distance from 0% to 100% to travel the path. It is not inherited, and it is part of the offset shorthand.

Baseline · Widely available.

Not deprecated and not experimental. Safe in current browsers since September 2022. Internet Explorer has no support.

CSS Syntax

syntax.css
offset-distance: <length-percentage> | initial | inherit;

Property Values

ValueDescriptionTry it
0%Start of the path. Same idea as the initial 0Try it
50%Halfway along the pathTry it
100%End of the pathTry it
80pxA fixed length along the pathTry it
0% → 100%Animate distance to travel the full pathTry it
initialSets this property to its default value, 0Try it
inheritInherits this property from the parent elementTry it

How to Use offset-distance

Define a path first, then set or animate how far along that path the element sits.

  1. Set an offset-path on the element.
  2. Set offset-distance to a percentage or length. It is not inherited.
  3. For motion, animate distance from 0% to 100% with @keyframes.
  4. Optionally add offset-rotate or offset-anchor.
PieceRequired?Role
offset-pathYesWithout a path, distance has nowhere to go
Percentage or lengthYesWhere the element sits on that path
animationFor motionChange distance over time to travel the path
Rotate / anchorNoFacing and which point sticks to the path

Live Preview

A marker sits on a straight path. Change offset-distance to move it from start to end.

Percentages scale with the path. A length is a fixed distance from the start.

Path

offset-distance: 0%

CSS Examples

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

Example 1 — Park at 50%

Place the element halfway along a straight path with no animation.

CSS
<style>
  div {
    width: 24px;
    height: 24px;
    background: #2563eb;
    offset-path: path("M 20 80 L 280 80");
    offset-distance: 50%;
    offset-rotate: 0deg;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Define the path. path("M 20 80 L 280 80") is a horizontal line.
  2. Set distance to halfway. 50% is relative to the full length of that path.
  3. Keep rotate fixed. 0deg keeps the box upright so you only study distance.
  4. No keyframes needed. A static percentage is enough to park the element.

Example 2 — Animate 0% to 100%

Travel the full path by animating offset-distance.

CSS
<style>
  @keyframes travel {
    from { offset-distance: 0%; }
    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. Same path as Example 1. Only the distance changes over time.
  2. Keyframe the distance. from starts at 0%. to ends at 100%.
  3. Let animation drive it. linear keeps a steady speed along the line.
  4. This is the usual motion pattern. Path stays fixed; distance does the traveling.

Example 3 — Length Along the Path

Use a fixed length when you want an exact distance from the start.

CSS
<style>
  div {
    width: 24px;
    height: 24px;
    background: #2563eb;
    offset-path: path("M 20 80 L 280 80");
    offset-distance: 80px;
    offset-rotate: 0deg;
  }
</style>

<div></div>
Try It Yourself

How It Works

  1. Lengths are absolute. 80px is 80 pixels from the path start, not 80% of the path.
  2. Path length still matters. If the path is shorter than 80px, the element sits at the end.
  3. Prefer % for full travel. Animating 0% to 100% always covers the whole path.
  4. Use lengths for exact stops. Handy when a marker must sit a fixed gap from the start.

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. Set a path before changing distance.

static

A fixed distance only parks

One value places the element. Animate from 0% to 100% when you want continuous motion.

%

Percentages use path length

50% is half of the path, not half of the viewport. A longer path makes the same percentage travel farther.

length

Lengths can overshoot

A length larger than the path clamps to the end. Prefer percentages when you always want full-path travel.

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

✓ Baseline · Widely available since 2022

offset-distance

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

Bottom line: Safe for modern motion-path demos. Pair with offset-path and animate 0% to 100% for full travel.

Key Takeaways

  • Role: how far along the path the element sits.
  • Scale: 0% start, 100% end. Initial value is 0.
  • Motion: animate distance; keep the path fixed.
  • Needs a path: set offset-path first. Not inherited.

One line: offset-distance is the progress along the path — park it with a value, or animate it to travel.

Frequently Asked Questions

It sets how far along an offset-path an element sits. 0% is the start of the path and 100% is the end.
0, which places the element at the beginning of the path.
Percentages are best for most animations because they scale with the path length. Use a length when you need an exact distance in px or another unit.
Yes. Without an offset-path, distance has nowhere to travel and nothing visible changes.
Set an offset-path, then animate offset-distance from 0% to 100% with @keyframes or a transition.
It is Baseline and widely available since September 2022: Chrome 55+, Firefox 72+, Safari 15.4+, and Edge 79+. Internet Explorer has no support. It is a browser CSS property, not a Node.js feature.

Next: offset-path

Learn how to define the curve or shape the distance travels on.

offset-path tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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