CSS offset Property

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

What You’ll Learn

The offset property belongs to the CSS Motion Path module. It lets you animate elements along curves, circles, and SVG paths instead of only moving them in straight lines with transform.

01

Motion Paths

Animate along a route.

02

Sub-properties

path, distance, anchor.

03

offset-path

Define the route.

04

offset-distance

Move along the path.

05

offset-rotate

Turn with the path.

06

@keyframes

Bring motion to life.

Introduction

The offset property in CSS is used to control animations along a predefined path. It is part of the CSS Motion Path specification and is used with the @keyframes rule to define animations.

The offset property specifies the position of an element along a path defined by the offset-path property, allowing for more complex and dynamic animations.

Definition and Usage

In practice, developers usually work with the individual motion path properties rather than a single magic keyword. Together they describe where the path is, how far along it the element has traveled, which point of the element sits on the path, and how the element rotates while moving.

This is ideal for loader animations, decorative motion, icon paths, and playful UI effects that follow curves instead of simple horizontal or vertical movement.

💡
Beginner Tip

Start with a visible path like a circle or rectangle, then animate offset-distance from 0% to 100% before adding rotation or anchor adjustments.

📝 Syntax

The offset property has several sub-properties that work together to define the animation’s behavior:

syntax.css
element {
  offset-path: path;
  offset-distance: distance;
  offset-anchor: position;
  offset-rotate: angle | auto | reverse;
}

Basic Example

offset-circle.css
.animated-box {
  offset-path: path("M 150,200 A 100,100 0 1 1 149,200");
  animation: moveInCircle 5s linear infinite;
}

@keyframes moveInCircle {
  from { offset-distance: 0%; }
  to { offset-distance: 100%; }
}

Syntax Rules

  • Define a path first with offset-path.
  • Animate progress with offset-distance, usually through @keyframes.
  • Use offset-anchor to choose which point of the element sits on the path.
  • Use offset-rotate when the element should turn to follow the path direction.

🎯 Default Value

The default values for the sub-properties are:

  • offset-path: none
  • offset-distance: 0
  • offset-anchor: auto
  • offset-rotate: auto

With these defaults, no motion path is active until you explicitly define a path and animate offset-distance.

⚡ Quick Reference

QuestionAnswer
ModuleCSS Motion Path
Main sub-propertiesoffset-path, offset-distance, offset-anchor, offset-rotate
Typical animation propertyoffset-distance
Common path formatspath(), circle(), ellipse(), SVG url()
Common usePath-based loaders, decorative motion, and curved UI animations

💎 Property Values

The motion path system is built from related properties. Each one controls a different part of the animation.

Sub-propertyExampleDescription
offset-pathpath("M 10 80 Q 95 10 180 80")Defines the path along which the element moves
offset-distanceoffset-distance: 50%;Specifies how far along the path the element is positioned
offset-anchoroffset-anchor: 50% 50%;Chooses the anchor point inside the element that sits on the path
offset-rotateoffset-rotate: auto;Controls rotation relative to the path direction

offset-path

Can use path(), SVG url(), or shapes like circle() and ray().

offset-distance

Accepts length or percentage values along the total path length.

offset-anchor

auto calculates from the element size; custom values shift the anchor point.

offset-rotate

auto, reverse, or a fixed angle such as 45deg.

offset-path — the route offset-distance — progress offset-anchor — anchor point offset-rotate — direction

👀 Live Preview

This dot follows a circular path using offset-path and an animated offset-distance:

Examples Gallery

Use motion path properties to animate elements along circles, rectangles, and custom curves.

🔄 Path Basics

Start with simple closed paths before building more complex motion effects.

Example 1 — Box Following a Circular Path

In this example, a box follows a circular path by animating offset-distance from start to finish.

circle-path.html
<style>
  @keyframes moveInCircle {
    from { offset-distance: 0%; }
    to { offset-distance: 100%; }
  }

  .animated-box {
    width: 50px;
    height: 50px;
    background-color: blue;
    offset-path: path("M 150,200 A 100,100 0 1 1 149,200");
    animation: moveInCircle 5s linear infinite;
  }
</style>

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

How It Works

The SVG-style path() function defines a circle, and the animation moves the element from 0% to 100% along that route.

Example 2 — Rectangle Path Animation

A small marker can travel around a rectangular border using a closed path and percentage-based distance.

rectangle-path.css
.marker {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #dc2626;
  offset-path: path("M10 10 H 290 V 290 H 10 Z");
  animation: travelBorder 6s linear infinite;
}

@keyframes travelBorder {
  to { offset-distance: 100%; }
}
Try It Yourself

How It Works

The path draws a rectangle with move and line commands. Animating offset-distance makes the marker travel around the border.

🎨 Advanced Motion

Combine curves, anchor points, and rotation for richer path animations.

Example 3 — Curved Path with offset-anchor

Use a curved SVG path and center the anchor point so the element sits naturally on the route.

curve-path.css
.dot {
  offset-path: path("M 10,80 Q 95,10 180,80 T 350,80");
  offset-anchor: 50% 50%;
  animation: followCurve 4s ease-in-out infinite alternate;
}

@keyframes followCurve {
  to { offset-distance: 100%; }
}
Try It Yourself

How It Works

The quadratic curve creates a wave-like route. offset-anchor: 50% 50% keeps the dot centered on the path line.

Example 4 — Rotation with offset-rotate

Make a shape turn to follow the path direction using offset-rotate: auto.

offset-rotate.css
.arrow {
  width: 24px;
  height: 24px;
  background: #9333ea;
  offset-path: circle(80px at 120px 80px);
  offset-rotate: auto;
  animation: orbit 5s linear infinite;
}

@keyframes orbit {
  to { offset-distance: 100%; }
}
Try It Yourself

How It Works

circle() defines a round orbit, and offset-rotate: auto aligns the element with the path tangent as it moves.

Related Motion Path Properties

The offset topic covers a family of properties. In real projects you will often see them split into dedicated pages such as offset-path, offset-distance, offset-anchor, and offset-rotate for finer control.

motion-path-set.css
.badge {
  offset-path: path("M 20,100 C 80,20 140,180 200,100");
  offset-distance: 0%;
  offset-anchor: center;
  offset-rotate: auto;
}

♿ Accessibility

  • Respect reduced motion — Wrap path animations in @media (prefers-reduced-motion: reduce) and provide a static fallback.
  • Do not rely on motion alone — Important status changes should also use text or icons.
  • Keep decorative motion subtle — Continuous looping paths can distract users with attention or vestibular sensitivity.
  • Test keyboard and screen reader flows — Motion should not block interaction with nearby controls.

🧠 How offset Works

1

You define a path

offset-path creates the route using SVG paths, circles, or other supported shapes.

offset-path
2

You move along the path

offset-distance sets how far the element has traveled, often animated with @keyframes.

Animation
3

You fine-tune anchor and rotation

offset-anchor and offset-rotate adjust how the element sits and turns on the path.

Refinement
=

Path-based motion

The element follows a custom route instead of a simple straight-line transform.

Browser Compatibility

The offset property and its associated sub-properties are relatively new. They are supported in modern versions of Chrome, Firefox, Safari, and Edge. Always check the latest browser support and consider fallbacks for unsupported browsers.

Baseline · Modern browsers

Growing support for motion paths

Current Chrome, Firefox, Safari, and Edge versions support motion path animations in most common use cases.

89% Modern browser support
Google Chrome 46+ · 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 33+ · Modern versions
Full support

Fallback behavior

When unsupported, elements remain static unless you provide a transform-based fallback animation.

💻
Internet Explorer No support · Use transform animations or JavaScript fallbacks
None
offset motion path properties 89% supported

Bottom line: Motion paths are safe for modern decorative animation, but test carefully and respect reduced-motion preferences.

Conclusion

The offset property in CSS provides a powerful tool for creating complex animations along predefined paths.

By controlling properties such as offset-path, offset-distance, offset-anchor, and offset-rotate, developers can create dynamic and engaging animations that enhance the user experience. Experiment with these properties to bring life and movement to your web projects.

💡 Best Practices

✅ Do

  • Start with a simple circle or rectangle path
  • Animate offset-distance with clear start and end values
  • Use offset-rotate: auto when direction matters
  • Respect prefers-reduced-motion for accessibility
  • Keep decorative motion subtle and purposeful

❌ Don’t

  • Confuse offset with top, right, bottom, or left
  • Assume every browser supports every path format equally
  • Overuse looping path animations on critical UI
  • Forget a static fallback for reduced-motion users
  • Make motion the only way to communicate important state

Key Takeaways

Knowledge Unlocked

Five things to remember about offset

Use these points when building path-based animations.

5
Core concepts
🛣 02

offset-path

Defines the route.

Path
📏 03

offset-distance

Controls progress.

Animation
📌 04

offset-anchor

Sets anchor point.

Alignment
🔄 05

offset-rotate

Turns with the path.

Direction

❓ Frequently Asked Questions

offset is part of the CSS Motion Path module. It helps animate an element along a predefined path using related properties such as offset-path and offset-distance.
No. Those inset properties move positioned elements in normal layout. offset is for motion-path animations along curves, circles, and SVG paths.
Common motion path properties include offset-path, offset-distance, offset-anchor, and offset-rotate.
Usually yes. Animating offset-distance from 0% to 100% is a common way to move an element along a path.
Modern Chrome, Firefox, Safari, and Edge support motion path properties, but you should test animations and provide fallbacks when needed.

Practice in the Live Editor

Open the HTML editor, define an offset-path, and animate motion along a custom route.

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