What Is offset-rotate?
The offset-rotate CSS property defines the orientation or direction of an element as it is positioned along the offset-path. In practical terms, when you animate an element along a curved or angled path, offset-rotate determines which way the element "faces" as it moves.
The property has undergone several name changes during its standardization process:
- motion-rotation (early drafts)
- offset-rotation (intermediate)
- offset-rotate (current)
This evolution reflects the property's position within the broader CSS offset shorthand property family.
The Motion Path System
Offset-rotate works with several related properties:
- offset-path: Defines the path shape
- offset-distance: Specifies position along the path
- offset-anchor: Defines the reference point within the element
- offset-position: Defines the offset position
Together, these properties create an offset transform that aligns a point in an element to a position on a path at various points along that path. This foundational understanding pairs well with learning about the CSS box model to build a solid base for modern CSS layout and animation techniques.
For teams implementing advanced CSS animations, understanding how these properties work together is essential for creating polished user experiences that feel natural and engaging.
Understanding the Values
auto
The auto value is the default for offset-rotate. The element is rotated by the angle of the direction of the offset-path, relative to the positive x-axis. This means the element automatically faces the direction it's moving.
reverse
The reverse value rotates the element similar to auto, except it faces the opposite direction. This is equivalent to auto 180deg.
Angle Values
Fixed angle values (such as 90deg, 180deg, 0.5turn) apply a constant clockwise rotation to the element regardless of its position on the path.
auto with Angle
The auto value can be combined with an additional angle: auto 45deg. The computed angle is added to the auto rotation, allowing the element to follow the path while maintaining a specific offset rotation.
Syntax Reference
/* Follow the path direction, with optional additional angle */
offset-rotate: auto;
offset-rotate: auto 45deg;
/* Follow the path direction but facing the opposite direction */
offset-rotate: reverse;
/* Keep a constant rotation regardless position on the path */
offset-rotate: 90deg;
offset-rotate: 0.5turn;
/* Global values */
offset-rotate: inherit;
offset-rotate: initial;
offset-rotate: revert;
offset-rotate: unset;
Practical Code Examples
Basic Path Following with auto
.marker {
width: 40px;
height: 40px;
background: #2bc4a2;
clip-path: polygon(0% 0%, 70% 0%, 100% 50%, 70% 100%, 0% 100%, 30% 50%);
offset-path: path("M20,20 C20,50 180,-10 180,20");
offset-rotate: auto;
animation: move 5000ms infinite alternate ease-in-out;
}
@keyframes move {
100% {
offset-distance: 100%;
}
}
The clip-path creates a triangle pointing to the right, and offset-rotate: auto ensures this triangle always points in the direction of travel.
Adding Fixed Rotation with auto angle
.car {
offset-rotate: auto 30deg;
/* Other offset and animation properties */
}
The element rotates to follow the path direction, but adds an additional 30-degree clockwise rotation.
Fixed Orientation Throughout Animation
.floating-icon {
offset-path: path("M10,50 Q50,10 90,50 T170,50");
offset-rotate: 0deg;
animation: slide 3000ms infinite linear;
}
The icon maintains its upright orientation throughout the entire path, even as the path curves.
Reversed Orientation
.backward-element {
offset-rotate: reverse;
/* Other offset and animation properties */
}
When implementing motion paths, consider combining these techniques with CSS generated content for creating rich animated interfaces that enhance user engagement without sacrificing performance.
Natural Animations
Elements automatically face their direction of travel, creating realistic motion effects
Baseline Support
Works across all modern browsers since September 2022 - safe for production use
Flexible Values
Choose from auto, reverse, fixed angles, or combine auto with offsets for precise control
Progressive Enhancement
Animations gracefully degrade for older browsers while enhancing experience for modern ones
Browser Support and Baseline Status
The offset-rotate property and the broader CSS Motion Path module have achieved Baseline status, meaning they work across many devices and browser versions and have been widely available since September 2022.
Current Browser Support
| Browser | Support | Notes |
|---|---|---|
| Chrome / Edge | Full support | Without flags since Chrome 46 |
| Firefox | Full support | Since Firefox 70 |
| Safari | Full support | macOS and iOS |
Progressive Enhancement
Given the current support levels, a progressive enhancement approach works well:
@media (prefers-reduced-motion: no-preference) {
.animated-element {
offset-path: path("M10,50 Q50,10 90,50");
offset-rotate: auto;
animation: move 2000ms infinite alternate;
}
}
For accessible web experiences, respecting user motion preferences is essential. Learn more about creating inclusive interfaces with CSS :target selector techniques that provide smooth fallback behaviors.
Best Practices
Matching Clip Paths to Path Direction
When using offset-rotate: auto, ensure your element's visual orientation matches the expected forward direction. A triangular clip-path pointing right works well when auto orientation is desired.
Performance Considerations
- Use CSS transforms rather than modifying position properties
- Prefer simple curves over highly complex paths
- Test animations on target devices
- Use the
will-changeproperty sparingly for complex animations
Accessibility
Always respect user preferences for reduced motion:
@media (prefers-reduced-motion: no-preference) {
.animated-element {
/* Animation styles */
}
}
Combining with Other Offset Properties
Offset-rotate works as part of the offset shorthand:
.element {
offset: path("M20,20 C20,50 180,-10 180,20") 0% auto;
/* Equivalent to setting offset-path, offset-distance, and offset-rotate separately */
}
Common Use Cases
- Animated illustrations: Characters or vehicles that move along paths
- Loading indicators: Spinning elements following circular paths
- Scroll-triggered animations: Elements that animate along paths as users scroll
- Interactive diagrams: Animated elements tracing connections between nodes
- Data visualization: Animated markers following chart paths
Mastering CSS motion paths like offset-rotate is just one aspect of professional web development services that deliver exceptional user experiences through thoughtful animation and modern CSS techniques.
Frequently Asked Questions
What is the default value of offset-rotate?
The default value is `auto`, which makes the element rotate to face the direction of the offset-path.
How do I make an element face backward along its path?
Use `offset-rotate: reverse`, which is equivalent to `auto 180deg`.
Can I combine auto with a fixed angle?
Yes, use syntax like `offset-rotate: auto 45deg` to follow the path direction while adding a 45-degree offset.
Is offset-rotate supported in all modern browsers?
Yes, offset-rotate has achieved Baseline status and works in Chrome, Firefox, Safari, and Edge since September 2022.
How does offset-rotate relate to the offset shorthand?
Offset-rotate is one of five properties that make up the offset shorthand. You can set it individually or as part of a combined offset declaration.