CSS offset-rotate Property

The CSS offset-rotate property controls the rotation of an element as it follows a motion path defined by offset-path.

It can automatically align an element with the direction of the path, reverse its orientation, or apply a fixed rotation angle. This is useful for moving icons, directional graphics, and other elements that need to maintain a particular orientation while traveling along a route.

offset-rotate Syntax

The offset-rotate property accepts an angle, the keyword auto, or the keyword reverse. The keywords can also be combined with an additional angle.

Basic Syntax

selector {
  offset-rotate: auto;
}

Automatic Rotation

.element {
  offset-rotate: auto;
}

Reverse Rotation

.element {
  offset-rotate: reverse;
}

Fixed Rotation

.element {
  offset-rotate: 0deg;
}
.element {
  offset-rotate: 45deg;
}
.element {
  offset-rotate: 90deg;
}

Automatic Rotation with an Additional Angle

.element {
  offset-rotate: auto 45deg;
}

Reverse Rotation with an Additional Angle

.element {
  offset-rotate: reverse 30deg;
}

Other Angle Units

.element {
  offset-rotate: 0.25turn;
}
.element {
  offset-rotate: 100grad;
}
.element {
  offset-rotate: 1rad;
}

Calculated Rotation

.element {
  offset-rotate: auto calc(30deg + 15deg);
}

CSS-Wide Keywords

.element {
  offset-rotate: initial;
}
.element {
  offset-rotate: inherit;
}
.element {
  offset-rotate: unset;
}
.element {
  offset-rotate: revert;
}
.element {
  offset-rotate: revert-layer;
}

The initial value is auto, which aligns the element's horizontal axis with the direction of the motion path.

Property Values

Value Description
auto Automatically rotates the element to align with the path's direction at its current position.
reverse Aligns the element with the path direction and adds a 180-degree rotation.
<angle> Applies a fixed rotation without automatically following the path's direction.
auto <angle> Aligns the element with the path and adds the specified rotation angle.
reverse <angle> Uses reverse alignment and adds the specified rotation angle.
initial Resets the property to auto.
inherit Uses the computed value from the parent element.
unset Resets the property to auto because it is not inherited.
revert Reverts the property according to cascade origin rules.
revert-layer Reverts the property according to cascade layer rules.

Property Characteristics

Characteristic Value
Initial value auto
Inherited No
Applies to Transformable elements
Computed value Specified keyword and angle, with the angle computed in degrees
Animation type By computed value type
Related shorthand offset

How It Works

The offset-rotate property determines the orientation of an element after the browser calculates its position along a motion path.

For automatic rotation, the browser determines the tangent direction of the path at the element's current position. The element is then rotated to follow that direction.

Step 1: Define a Motion Path

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
}

The path forms a curve between two points.

Step 2: Select a Position

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 25%;
}

The element is positioned one-quarter of the way along the route.

Step 3: Enable Automatic Rotation

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 25%;
  offset-rotate: auto;
}

The element rotates to match the direction of the curve at that position.

Step 4: Apply a Fixed Orientation

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 25%;
  offset-rotate: 0deg;
}

The element remains at its normal orientation rather than following the curve's direction.

Important Consideration

offset-rotate controls orientation, not the distance traveled. Changing its value does not change the geometry of the motion path.

The auto Value

The auto keyword automatically aligns the element with the tangent direction of its motion path.

As the element moves around a curve, its rotation changes to follow the direction of travel.

Automatic Rotation on a Curve

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: auto;
}

The element aligns with the curve's direction at the halfway point.

Automatic Rotation on a Straight Line

.element {
  offset-path: path("M 0 0 L 250 0");
  offset-distance: 50%;
  offset-rotate: auto;
}

The path extends horizontally to the right, so its tangent direction is horizontal.

Automatic Rotation on a Diagonal Line

.element {
  offset-path: path("M 0 0 L 200 200");
  offset-distance: 50%;
  offset-rotate: auto;
}

The element rotates to align with the diagonal path.

Automatic Rotation on a Circle

.element {
  offset-path: circle(80px);
  offset-distance: 25%;
  offset-rotate: auto;
}

The element aligns with the tangent to the circle at its current position.

Important Consideration

Automatic rotation aligns the element's positive horizontal axis with the path tangent. Graphics that naturally face upward or in another direction may require an additional angle.

The reverse Value

The reverse keyword aligns the element with the path tangent and adds a 180-degree rotation.

This makes the element face opposite the path's forward direction.

Reverse Rotation on a Curve

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: reverse;
}

The element follows the curve's tangent but faces the opposite direction.

Reverse Rotation on a Straight Line

.element {
  offset-path: path("M 0 0 L 250 0");
  offset-distance: 50%;
  offset-rotate: reverse;
}

Although the path extends to the right, the element is rotated to face left.

Reverse Rotation on a Circle

.element {
  offset-path: circle(80px);
  offset-distance: 50%;
  offset-rotate: reverse;
}

The element aligns with the circular tangent in the opposite orientation.

Important Consideration

reverse changes the element's orientation. It does not reverse the direction of movement along the path. To reverse travel, change the animation or the progression of offset-distance.

Angle Values

An angle value specifies a fixed rotation without automatically aligning the element with the path direction.

No Additional Rotation

.element {
  offset-rotate: 0deg;
}

The motion-path rotation is zero degrees, so the element does not turn to follow the path.

45-Degree Rotation

.element {
  offset-rotate: 45deg;
}

The element is rotated 45 degrees clockwise.

90-Degree Rotation

.element {
  offset-rotate: 90deg;
}

The element is rotated 90 degrees clockwise.

Negative Rotation

.element {
  offset-rotate: -45deg;
}

The element is rotated 45 degrees counterclockwise.

Turn Units

.element {
  offset-rotate: 0.25turn;
}

One-quarter of a turn is equivalent to 90 degrees.

Angle Unit Reference

Unit Description Full Rotation
deg Degrees 360deg
grad Gradians 400grad
rad Radians Approximately 6.283185rad
turn Turns 1turn

Important Consideration

A standalone angle creates a fixed motion-path rotation. Use auto with an angle when the element should follow the path direction while maintaining an additional rotation.

Combining auto with an Angle

The auto keyword can be combined with an angle to adjust the element's orientation relative to the path tangent.

Automatic Rotation Plus 45 Degrees

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: auto 45deg;
}

The element aligns with the path and receives an additional 45-degree clockwise rotation.

Automatic Rotation Minus 90 Degrees

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: auto -90deg;
}

The element follows the path tangent with an additional 90-degree counterclockwise adjustment.

Correcting an Upward-Facing Icon

.direction-icon {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: auto 90deg;
}

An icon designed to face upward can use an additional rotation to align its visual direction with the route.

Equivalent Value Order

.element {
  offset-rotate: auto 45deg;
}
.element {
  offset-rotate: 45deg auto;
}

Both declarations express automatic alignment with an additional 45-degree rotation.

Important Consideration

The additional angle is applied relative to the path tangent, so the element continues to rotate as it moves along a curved route.

Combining reverse with an Angle

The reverse keyword can also be combined with an angle to adjust the reversed orientation.

Reverse with 30 Degrees

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: reverse 30deg;
}

The element receives the reverse alignment plus an additional 30-degree rotation.

Reverse with Negative Rotation

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: reverse -45deg;
}

The element uses reverse alignment with a 45-degree counterclockwise adjustment.

Reverse with 90 Degrees

.element {
  offset-path: path("M 0 0 L 250 0");
  offset-distance: 50%;
  offset-rotate: reverse 90deg;
}

The element faces opposite the horizontal path direction with an additional quarter-turn.

Equivalent Rotation

.element {
  offset-rotate: reverse 30deg;
}
.element {
  offset-rotate: auto 210deg;
}

These declarations produce equivalent orientations because reverse adds 180 degrees to the automatic alignment.

Important Consideration

Use reverse when the intent is to face opposite the path tangent. Use auto with a suitable angle when a different directional adjustment is required.

Path Direction and Rotation

The direction in which a path is defined affects automatic rotation.

For straight lines, the tangent direction is constant. For curves, it changes along the route.

Left-to-Right Path

.element {
  offset-path: path("M 0 0 L 200 0");
  offset-distance: 50%;
  offset-rotate: auto;
}

The tangent points to the right.

Right-to-Left Path

.element {
  offset-path: path("M 200 0 L 0 0");
  offset-distance: 50%;
  offset-rotate: auto;
}

The tangent points to the left, producing an orientation 180 degrees different from the previous example.

Downward Path

.element {
  offset-path: path("M 0 0 L 0 200");
  offset-distance: 50%;
  offset-rotate: auto;
}

The tangent points downward.

Upward Path

.element {
  offset-path: path("M 0 200 L 0 0");
  offset-distance: 50%;
  offset-rotate: auto;
}

The tangent points upward.

Curved Path

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 75%;
  offset-rotate: auto;
}

The element aligns with the curve's tangent at the three-quarter point.

Important Consideration

Reversing an animation with animation-direction: alternate does not automatically reverse the path's defined tangent. The auto orientation is based on the path geometry, not the animation's current travel direction.

Using offset-path

The offset-path property defines the route used to calculate automatic rotation.

Straight Path

.element {
  offset-path: path("M 0 0 L 250 0");
  offset-rotate: auto;
}

The element aligns with the horizontal route.

Curved Path

.element {
  offset-path: path("M 0 100 C 100 -50 200 250 300 100");
  offset-rotate: auto;
}

The element's orientation changes according to the curve's tangent.

Circular Path

.element {
  offset-path: circle(80px);
  offset-rotate: auto;
}

The element aligns with the tangent of the circular route.

Elliptical Path

.element {
  offset-path: ellipse(120px 60px);
  offset-rotate: auto;
}

The element follows the changing tangent direction around an ellipse.

Ray Path

.element {
  offset-position: center;
  offset-path: ray(90deg closest-side);
  offset-rotate: auto;
}

The element aligns with the ray's direction.

Important Consideration

When offset-path is none, there is no motion-path tangent to follow. A standalone angle can still contribute a fixed rotation through the motion-path transform.

Using offset-distance

The offset-distance property determines the element's position along the path. When offset-rotate is auto or reverse, changing the distance can also change its orientation.

Beginning of a Curve

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 0%;
  offset-rotate: auto;
}

The element aligns with the tangent at the beginning of the curve.

Middle of a Curve

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: auto;
}

The element aligns with the tangent at the midpoint.

End of a Curve

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 100%;
  offset-rotate: auto;
}

The element aligns with the tangent at the endpoint.

Fixed Rotation at Different Distances

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 75%;
  offset-rotate: 0deg;
}

The element moves to the selected position without changing its motion-path rotation to match the curve.

Important Consideration

The path's tangent is evaluated at the position determined by offset-distance. This is why automatic rotation changes naturally during motion along a curve.

Using offset-anchor

The offset-anchor property identifies which point within the element is attached to the motion path.

It works with offset-rotate to determine how the element is positioned and oriented around that attachment point.

Center Anchor

.element {
  offset-path: path("M 0 0 L 250 0");
  offset-distance: 50%;
  offset-anchor: center;
  offset-rotate: auto;
}

The element's center follows the route.

Left-Center Anchor

.element {
  offset-path: path("M 0 0 L 250 0");
  offset-distance: 50%;
  offset-anchor: left center;
  offset-rotate: auto;
}

The midpoint of the element's left edge follows the route.

Custom Anchor

.element {
  offset-path: path("M 0 0 L 250 0");
  offset-distance: 50%;
  offset-anchor: 25% 75%;
  offset-rotate: auto;
}

A custom point within the element is attached to the path.

Important Consideration

Changing the anchor can noticeably change the element's visual placement during rotation, even when the path and distance remain unchanged.

offset-rotate vs. transform

Both offset-rotate and transform: rotate() can rotate an element, but they serve different purposes.

Using offset-rotate

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: auto;
}

The element's orientation is calculated from the path tangent.

Using transform

.element {
  transform: rotate(45deg);
}

The element receives a fixed rotation without requiring a motion path.

Combining Both Properties

.element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: auto;
  transform: rotate(20deg);
}

The motion-path rotation and the additional transform both contribute to the final appearance.

Comparison Table

Feature offset-rotate transform: rotate()
Primary purpose Control motion-path orientation Apply a general rotation transform
Automatic path alignment Yes, with auto No
Fixed angle Yes Yes
Requires a motion path for automatic alignment Yes Not applicable
Can be animated Yes Yes
Works with other transforms Yes Yes

Important Consideration

Motion-path transforms and ordinary CSS transforms are combined in a defined order. If both properties are used, test the resulting orientation rather than assuming they behave as independent visual layers.

Using the offset Shorthand

The offset shorthand combines motion-path properties into a single declaration.

Longhand Version

.element {
  offset-path: path("M 0 0 L 200 0");
  offset-distance: 50%;
  offset-rotate: auto 30deg;
  offset-anchor: center;
}

Shorthand Version

.element {
  offset: path("M 0 0 L 200 0") 50% auto 30deg / center;
}

The shorthand defines the path, distance, rotation, and anchor.

Path with Fixed Rotation

.element {
  offset: path("M 0 0 L 200 0") 50% 0deg;
}

The element is positioned halfway along the route with a fixed motion-path rotation.

Path with Automatic Rotation

.element {
  offset: path("M 0 0 L 200 0") 50% auto;
}

The element aligns with the direction of the route.

Shorthand Reset Behavior

.element {
  offset-rotate: 45deg;
  offset: path("M 0 0 L 200 0") 50%;
}

The shorthand resets offset-rotate to its initial value of auto because no rotation value is included.

Preserving a Rotation Override

.element {
  offset: path("M 0 0 L 200 0") 50%;
  offset-rotate: 45deg;
}

Declaring the longhand after the shorthand preserves the intended fixed rotation.

Animating offset-rotate

The offset-rotate property can be animated between compatible angle values. It can also update automatically as offset-distance changes along a curved path.

Automatic Rotation During Motion

.moving-element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 0%;
  offset-rotate: auto;
  animation: move-route 4s linear infinite;
}
@keyframes move-route {
  to {
    offset-distance: 100%;
  }
}

The element rotates naturally as it travels along the curve.

Fixed Rotation During Motion

.moving-element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 0%;
  offset-rotate: 0deg;
  animation: move-route 4s linear infinite;
}

The element moves along the curve without turning to match its direction.

Animating a Fixed Angle

.rotating-element {
  offset-path: path("M 0 0 L 250 0");
  offset-distance: 50%;
  offset-rotate: 0deg;
  animation: rotate-on-path 3s linear infinite;
}
@keyframes rotate-on-path {
  to {
    offset-rotate: 360deg;
  }
}

The element rotates through a full turn while remaining at the same position on the path.

Animating an Additional Angle

.rotating-element {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: auto 0deg;
  animation: adjust-rotation 3s ease-in-out infinite alternate;
}
@keyframes adjust-rotation {
  to {
    offset-rotate: auto 90deg;
  }
}

The element remains aligned with the path while its additional rotation changes.

Reduced Motion

@media (prefers-reduced-motion: reduce) {
  .moving-element,
  .rotating-element {
    animation: none;
  }
}

This media query disables nonessential motion for users who request reduced motion.

Important Consideration

Animating between compatible angle values produces smooth rotation. Switching between automatic alignment and fixed rotation may not interpolate in the same way, so test transitions between different value types.

Practical Uses

The offset-rotate property is useful whenever an element needs to maintain a meaningful orientation along a motion path.

Directional Arrows

.route-arrow {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: auto;
}

An arrow can follow the path's tangent to indicate its direction.

Moving Vehicle Icon

.vehicle-icon {
  offset-path: path("M 0 150 C 100 0 200 250 300 100");
  offset-distance: 50%;
  offset-rotate: auto;
}

A vehicle graphic can turn naturally along a curved route.

Upright Labels

.moving-label {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: 0deg;
}

A text label can follow a path while remaining horizontally oriented.

Reverse-Facing Graphic

.reverse-icon {
  offset-path: path("M 0 0 L 250 0");
  offset-distance: 50%;
  offset-rotate: reverse;
}

A graphic can face opposite the route's defined direction.

Custom Directional Adjustment

.custom-icon {
  offset-path: path("M 0 100 Q 150 -100 300 100");
  offset-distance: 50%;
  offset-rotate: auto 90deg;
}

An additional angle can compensate for the original orientation of an icon or illustration.

offset-rotate Example

This example compares automatic rotation with fixed rotation along the same curved path. The blue arrow follows the curve's direction, while the green arrow remains horizontally oriented.

HTML Example

<div class="rotation-demo">
  <svg viewBox="0 0 320 180" aria-hidden="true">
    <path d="M 20 140 Q 160 -100 300 140" fill="none" stroke="#94a3b8" stroke-width="3" stroke-dasharray="6 5"></path>
  </svg>
  <div class="rotation-arrow arrow-auto">&#10140;</div>
  <div class="rotation-arrow arrow-fixed">&#10140;</div>
</div>

CSS Example

.rotation-demo {
  position: relative;
  width: 320px;
  height: 180px;
  max-width: 100%;
}
.rotation-demo svg {
  display: block;
  width: 100%;
  height: 100%;
}
.rotation-arrow {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  offset-path: path("M 20 140 Q 160 -100 300 140");
  offset-distance: 35%;
  offset-anchor: center;
}
.arrow-auto {
  background-color: #2563eb;
  offset-rotate: auto;
}
.arrow-fixed {
  background-color: #16a34a;
  offset-distance: 65%;
  offset-rotate: 0deg;
}
Browser Result
➜
➜

The blue arrow uses offset-rotate: auto, so it aligns with the tangent of the curve at 35% of the path. The green arrow uses offset-rotate: 0deg, so it remains horizontally oriented at 65% of the path.

Animated Rotation Example

The following example animates an arrow along a curved path while automatically adjusting its orientation.

<div class="animated-rotation-demo">
  <div class="animated-arrow">&#10140;</div>
</div>
.animated-rotation-demo {
  position: relative;
  width: 320px;
  height: 180px;
  max-width: 100%;
}
.animated-arrow {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #2563eb;
  color: #fff;
  font-size: 22px;
  offset-path: path("M 20 140 Q 160 -100 300 140");
  offset-distance: 0%;
  offset-anchor: center;
  offset-rotate: auto;
  animation: follow-curve 4s linear infinite;
}
@keyframes follow-curve {
  to {
    offset-distance: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  .animated-arrow {
    animation: none;
    offset-distance: 50%;
  }
}

The arrow follows the curved route and rotates continuously to match the path tangent.

Common Mistakes

Confusing auto with a Fixed Rotation

auto follows the path tangent, while a standalone angle creates a fixed motion-path rotation.

Assuming reverse Changes Travel Direction

reverse changes orientation by 180 degrees. It does not change the direction in which offset-distance progresses.

Forgetting the Path Direction

Automatic rotation depends on the path's defined direction. Reversing the path coordinates changes the tangent orientation.

Expecting auto to Match an Icon's Natural Facing Direction

Automatic alignment uses the element's positive horizontal axis. An icon that naturally faces upward may need an additional angle.

Confusing offset-rotate with transform: rotate()

offset-rotate controls motion-path orientation, while transform: rotate() applies a general CSS rotation.

Ignoring the Anchor Point

Changing offset-anchor can alter how the element appears to rotate around the path.

Forgetting the Shorthand Reset

.element {
  offset-rotate: 45deg;
  offset: path("M 0 0 L 200 0") 50%;
}

The shorthand resets offset-rotate to auto.

Using an Angle Without a Unit

.element {
  offset-rotate: 45;
}

Nonzero angle values require a valid angle unit, such as deg, rad, grad, or turn.

Assuming Animation Reversal Changes Orientation

Reversing the direction of an animation does not automatically reverse the path tangent used by auto.

Ignoring Reduced-Motion Preferences

Continuous movement and rotation can be distracting. Provide a reduced-motion alternative when animation is not essential.

Important Considerations

Keep the following points in mind when using offset-rotate:

  • The property controls the orientation of an element along a CSS motion path.
  • Its initial value is auto.
  • The property is not inherited.
  • It applies to transformable elements.
  • It is a longhand property of the offset shorthand.
  • auto aligns the element's positive horizontal axis with the path tangent.
  • reverse adds 180 degrees to automatic alignment.
  • A standalone angle specifies a fixed motion-path rotation.
  • auto and reverse can be combined with additional angles.
  • Supported angle units include deg, grad, rad, and turn.
  • Positive angles rotate clockwise in the usual CSS coordinate system.
  • Negative angles rotate counterclockwise in the usual CSS coordinate system.
  • The path's defined direction determines its tangent orientation.
  • Curved paths can produce continuously changing automatic rotation.
  • Straight paths have a constant tangent direction.
  • offset-distance determines where the tangent is evaluated.
  • offset-anchor affects the element's placement relative to the path.
  • offset-position can influence the starting point of applicable paths.
  • Automatic rotation does not change the path geometry.
  • reverse does not reverse movement along the path.
  • Motion-path rotation can be combined with other CSS transforms.
  • Fixed angle values can be animated.
  • Additional angles can correct the natural orientation of directional graphics.
  • The offset shorthand resets omitted motion-path longhands.
  • Provide reduced-motion alternatives for nonessential animations.
  • Test the path, distance, anchor, and rotation together to verify the final appearance.

Browser Support

The CSS offset-rotate property is Baseline - Widely available and is supported in current versions of major browsers, including Chrome, Edge, Firefox, and Safari.

Support for the property is established, but compatibility may vary for newer motion-path features used alongside it, such as certain offset-path shapes, ray options, and SVG URL references.

For current compatibility information, visit Can I Use? and search for offset-rotate.

When combining offset-rotate with newer motion-path syntax, verify support for the complete feature combination.

Specifications

The offset-rotate property is defined in CSS Motion Path Module Level 1.

CSS Motion Path Module Level 1: The offset-rotate Property

The specification defines how automatic and fixed rotations are calculated along motion paths, including tangent alignment and additional angle adjustments.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: offset-rotate