CSS offset-anchor Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Animation & Motion

What You’ll Learn

The offset-anchor property controls which point inside an element sits on the motion path. It helps path animations look precise instead of floating above or below the route.

01

Anchor Point

Point on the element box.

02

Syntax

Use position values.

03

auto Default

Browser chooses anchor.

04

Keywords

top, center, bottom.

05

Percentages

Fine-tune placement.

06

Motion Path

Works with offset-path.

Introduction

The offset-anchor property in CSS is part of the CSS Motion Path Module, which allows you to define an animation path for an element. The offset-anchor property specifies the position of the element relative to the path.

This property is particularly useful for creating animations along complex paths, as it allows you to control where the element is anchored on the path.

Definition and Usage

When an element moves along an offset-path, the browser must decide which part of the element touches the path line. That decision is made by offset-anchor.

For example, centering the anchor with 50% 50% makes a square ride smoothly on the path, while top left can make the same square appear to hang below the route.

💡
Beginner Tip

If your animated shape looks misaligned on the path, adjust offset-anchor before changing the path itself.

📝 Syntax

The syntax for the offset-anchor property is:

syntax.css
element {
  offset-anchor: <position>;
}

Here, <position> can be a set of values defining the anchor point relative to the element’s box.

Basic Example

offset-anchor.css
.box {
  offset-path: path("M 10,80 Q 95,10 180,80 T 350,80");
  offset-anchor: 50% 50%;
  animation: move 5s infinite alternate;
}

Syntax Rules

  • Define a path with offset-path before adjusting the anchor.
  • Use keywords, percentages, or lengths like other CSS position values.
  • auto is the default and usually works for simple square elements.
  • Custom anchors are most helpful for non-square shapes or precise visual alignment.

🎯 Default Value

The default value of the offset-anchor property is auto, which means the element’s position is automatically calculated based on the element’s size and the path.

In many beginner demos, auto and center look similar, but explicit values give you predictable control when the element is wider, taller, or irregularly shaped.

⚡ Quick Reference

QuestionAnswer
Initial valueauto
Applies toElements with a defined offset-path
InheritedNo
AnimatableYes, as a position
Common useFine-tuning motion path animations

💎 Property Values

ValueExampleDescription
autooffset-anchor: auto;Lets the browser determine the anchor automatically
Keywordsoffset-anchor: top left;Uses values such as top, center, bottom, and right
Percentagesoffset-anchor: 50% 50%;Places the anchor using horizontal and vertical percentages
Lengthsoffset-anchor: 10px 20px;Uses exact distances from the top-left of the element box
auto — default center — balanced ride top left — corner anchor 50% 50% — exact center

👀 Live Preview

These boxes follow the same curved path. Only the offset-anchor value changes:

center
top left
bottom center

Examples Gallery

Adjust the anchor point to control how an element sits on its motion path.

📌 Anchor Basics

Start with centered anchors before experimenting with corners and edges.

Example 1 — Centered Anchor on a Curved Path

In this example, a box follows a curved path with its anchor point set at the center of the box.

center-anchor.html
<style>
  .box {
    width: 50px;
    height: 50px;
    background-color: blue;
    offset-path: path("M 10,80 Q 95,10 180,80 T 350,80");
    offset-anchor: 50% 50%;
    animation: move 5s infinite alternate;
  }

  @keyframes move {
    to { offset-distance: 100%; }
  }
</style>

<div class="box"></div>
Try It Yourself

How It Works

The center of the box stays on the path line, which is the most common choice for balanced motion effects.

Example 2 — Default auto Anchor

With auto, the browser calculates the anchor automatically based on the element and path.

auto-anchor.css
.marker {
  offset-path: circle(70px at 120px 80px);
  offset-anchor: auto;
  animation: orbit 4s linear infinite;
}
Try It Yourself

How It Works

auto is a good starting point when you do not need pixel-perfect alignment on the path.

🎯 Anchor Variations

Corner and edge anchors change how the same path animation feels visually.

Example 3 — top left Anchor

Anchoring the top-left corner makes the element appear to trail below and to the right of the path.

top-left-anchor.css
.badge {
  width: 40px;
  height: 24px;
  offset-path: path("M 20,90 C 80,20 140,160 200,90");
  offset-anchor: top left;
  animation: slide 4s ease-in-out infinite alternate;
}
Try It Yourself

How It Works

The top-left corner touches the path, so the rest of the element extends downward and rightward from the route.

Example 4 — bottom center Anchor

Use a bottom anchor when you want a shape to sit above the path like a marker hovering over a line.

bottom-anchor.css
.pin {
  width: 18px;
  height: 18px;
  offset-path: path("M 10,70 L 250,70");
  offset-anchor: bottom center;
  animation: travel 3s linear infinite alternate;
}
Try It Yourself

How It Works

The bottom-center point rides on the path, so the marker appears to stand above the line.

Pair with offset-path and offset-distance

offset-anchor does not create motion by itself. You still need a path from offset-path and movement from offset-distance or an animation that changes distance along the route.

motion-path-set.css
.dot {
  offset-path: path("M 10,80 Q 95,10 180,80");
  offset-distance: 0%;
  offset-anchor: center;
}

♿ Accessibility

  • Respect reduced motion — Disable or simplify path animations inside prefers-reduced-motion media queries.
  • Keep motion decorative — Do not rely on path animation alone to communicate essential information.
  • Avoid distracting loops — Continuous motion can make nearby text harder to read.
  • Test visual clarity — A poor anchor choice can make motion harder to follow, especially for low-vision users.

🧠 How offset-anchor Works

1

A path is defined

offset-path creates the route the element will follow.

offset-path
2

You choose an anchor point

offset-anchor picks which part of the element sits on that path.

Anchor
3

Distance moves the element

As offset-distance changes, the chosen anchor travels along the route.

Motion
=

Precise path alignment

The element follows the path from the exact point you selected inside its box.

Browser Compatibility

The offset-anchor property is a relatively new motion path feature. It is supported in modern versions of Chrome, Firefox, Safari, and Edge. Check compatibility and provide fallback animations for older browsers.

Baseline · Modern browsers

Growing support in current browsers

Motion path properties including offset-anchor work in most up-to-date browser versions.

88% 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

Fallback behavior

When unsupported, the element may remain static or ignore the custom anchor point.

💻
Internet Explorer No support · Use transform-based animation fallbacks
None
offset-anchor property 88% supported

Bottom line: Use offset-anchor as progressive enhancement for decorative motion path effects.

Conclusion

The offset-anchor property provides greater control over animations along a path by specifying the anchor point of the element. This can be particularly useful for fine-tuning animations and creating complex motion effects.

By understanding and using offset-anchor, you can enhance the visual appeal of your web projects and create more engaging user experiences.

💡 Best Practices

✅ Do

  • Start with center or 50% 50% for square elements
  • Adjust the anchor when the element looks off the path
  • Pair with offset-path and animated offset-distance
  • Test different anchors for wide or tall shapes
  • Respect reduced-motion preferences

❌ Don’t

  • Confuse offset-anchor with scroll-driven animation anchors
  • Expect visible results without an offset-path
  • Assume auto always equals center for every shape
  • Use complex motion when a simple transform would suffice
  • Forget browser support testing for motion path features

Key Takeaways

Knowledge Unlocked

Five things to remember about offset-anchor

Use these points when fine-tuning motion path animations.

5
Core concepts
02

auto Default

Browser decides.

Default
📝 03

Keywords

top, center, bottom.

Values
📐 04

Percentages

Exact placement.

Precision
🛣 05

Motion Path

Needs offset-path.

Companion

❓ Frequently Asked Questions

offset-anchor defines which point inside an element is placed on the motion path defined by offset-path.
The default value is auto, which lets the browser calculate the anchor based on the element size and path.
object-position aligns replaced content inside a box. offset-anchor aligns an element on a motion path during path-based animation.
Yes. You can use values such as center, top left, bottom center, or percentages like 50% 50%.
Change it when the element looks offset from the path line, such as when a tall shape wobbles above or below the route instead of sitting on it.

Practice in the Live Editor

Open the HTML editor, set an offset-path, and experiment with different anchor points.

HTML Editor →

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.

5 people found this page helpful