CSS offset-anchor Property

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

Definition and Usage

The offset-anchor property picks which point inside an element sits on an offset-path. Only that point rides the path; the rest of the box hangs around it.

The initial value is auto, which usually matches transform-origin. If there is no path, auto follows offset-position instead. It is not inherited. You can also set it in the offset shorthand after a slash.

Baseline · Widely available.

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

CSS Syntax

syntax.css
offset-anchor: auto | <position> | initial | inherit;

A position uses the same grammar as background-position: keywords, percentages, lengths, or an edge offset.

Property Values

ValueDescriptionTry it
autoDefault. Usually the same point as transform-originTry it
centerPins the center of the box to the pathTry it
top rightPins the top-right corner to the pathTry it
bottom leftPins the bottom-left corner to the pathTry it
20% 80%Percentage point inside the box (x then y)Try it
initialSets this property to its default value, autoTry it
inheritInherits this property from the parent elementTry it

How to Use offset-anchor

Give the element a path, park it on that path, then choose which point of the box touches the line.

  1. Set an offset-path on the element.
  2. Set offset-distance (or animate it) so the element is on the path.
  3. Set offset-anchor to auto, a keyword pair, or a percentage. It is not inherited.
  4. Keep offset-rotate: 0deg while learning so rotation does not hide the anchor change.
PieceRequired?Role
offset-pathYesThe line or curve the anchor point follows
offset-distanceUsuallyWhere along the path that point sits
Anchor valueYesWhich point inside the box is glued to the path
A visible box sizeYesCorner anchors are hard to see on a tiny element

Live Preview

The gray line is the path. The blue box stays at 50% distance. Change offset-anchor and watch which point sits on the line.

Only the anchor point touches the path. The rest of the box hangs around that point.

Path

offset-anchor: auto

CSS Examples

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

Example 1 — Default auto

Use the default anchor so the box’s usual origin (often the center) rides the path.

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

<div></div>
Try It Yourself

How It Works

  1. Draw a path. The line from (20, 80) to (280, 80) is the route.
  2. Park at halfway. offset-distance: 50% places the element in the middle of that line.
  3. Keep rotate fixed. 0deg stops the box from tipping, so the anchor is easy to see.
  4. Use auto. The browser picks the same point as transform-origin (usually the center) to sit on the path.

Example 2 — Corner on the Path

Pin the top-right corner to the path so the box hangs below and to the left of the line.

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

<div></div>
Try It Yourself

How It Works

  1. Same path and distance. Only the anchor changes from Example 1.
  2. Pin one corner. top right puts that corner on the gray path line.
  3. The box hangs off the path. Everything except that corner sits below and to the left.
  4. Try bottom left. That corner rides the line instead, and the box flips to the other side.

Example 3 — Percentage Anchor

Place a custom point inside the box on the path with percentages.

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

<div></div>
Try It Yourself

How It Works

  1. Two values mean x then y. 20% is from the left of the box. 80% is from the top.
  2. That point sits on the path. Percentages are relative to the element’s own width and height.
  3. 50% 50% is the center. That matches the everyday center keyword.
  4. Fine-tune hang. Use percentages when keywords are too coarse for the shape you are animating.

Edge Cases & Pitfalls

If the box looks disconnected from the path, one of these is usually why.

path

Needs an offset-path

Without offset-path, there is no line to anchor to. Set the path first, then the anchor.

size

Tiny boxes hide corner changes

On a 8px marker, top right and center look almost the same. Use a larger box while you learn.

rotate

auto rotate can confuse the demo

offset-rotate: auto tips the box with the path. Use 0deg when you only want to study the anchor point.

auto

auto follows another property

With a path, auto matches transform-origin. With no path, it follows offset-position.

slash

Shorthand needs a slash

In offset, write the anchor after /: offset: path("…") 50% 0deg / top right.

Browser Support

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

✓ Baseline · Widely available since 2023

offset-anchor

Chrome 116+, Firefox 72+, Safari 16+, Edge 116+. Internet Explorer has no native support.

93% Modern browser support
Google Chrome 116+ · Desktop & Mobile
Full support
Mozilla Firefox 72+ · Desktop & Mobile
Full support
Apple Safari 16+ · macOS & iOS
Full support
Microsoft Edge 116+ · Chromium
Full support
Opera 102+ · Modern versions
Full support
Samsung Internet 23+ · Android
Full support
Internet Explorer No support
None
offset-anchor Widely supported

Bottom line: Safe for modern motion-path demos. Baseline since August 2023. Pair with offset-path and a clear box size so corner anchors are easy to see.

Key Takeaways

  • Role: choose which point inside the element sits on the motion path.
  • Default: auto — usually matches transform-origin. Not inherited.
  • Needs a path: set offset-path first, then the anchor.
  • Values: keywords, percentages, or lengths — same idea as background-position.

One line: offset-anchor glues one point of the box to the path; the rest of the box hangs around that point.

Frequently Asked Questions

It picks which point inside an element sits on the offset-path. For example, top right pins that corner to the path while the rest of the box hangs off it.
auto. That usually matches the element's transform-origin. If offset-path is none, auto follows offset-position instead.
transform-origin is the pivot for transforms. offset-anchor is the point glued to a motion path. With auto, offset-anchor often uses the same point as transform-origin.
The path touches only the anchor point. If you set top left, that corner rides the path and the rest of the box sits below and to the right of the line.
Yes. Without a path, there is nowhere to anchor. Pair offset-anchor with offset-path, then place or animate offset-distance.
It is Baseline and widely available since August 2023: Chrome 116+, Firefox 72+, Safari 16+, and Edge 116+. Internet Explorer has no support. It is a browser CSS property, not a Node.js feature.

Next: offset-distance

Learn how far along the path the anchored point travels.

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