CSS propertyTransforms

rotate

Rotates an element by a given angle, independently of the transform property.

Initial value
none
Inherited
No
Animatable
yes, as an angle
Applies to
transformable elements
JavaScript
element.style.rotate = "45deg"
On this page

Example

#
CSS
.chevron {
  transition: rotate 0.2s;
}

details[open] .chevron {
  rotate: 180deg;
}
Preview

Definition and usage

#

The rotate property rotates an element around the transform-origin point. You give the angle in degrees (deg), turns (turn), or radians (rad). Positive values rotate clockwise.

If you put an axis before the angle, for example rotate: y 60deg, you get a 3D rotation around the chosen axis. The depth effect appears when the parent has perspective set.

The property works independently of transform, so you can animate the rotation alone and set translation and scale separately.

Syntax

#
Syntax
rotate: none | <angle> | <axis> <angle>;

Values

#
  • none

    No rotation.
  • 45deg

    Rotates 45 degrees.
  • -0.1turn

    Rotates one tenth of a full turn, counterclockwise.
  • x 60deg

    3D rotation

    Rotation around the horizontal axis. Without perspective, the element simply flattens.

Values in practice

#

none

No rotation.
.demo { rotate: none; }

45deg

Rotates 45 degrees.
.demo { rotate: 45deg; }

-0.1turn

Rotates one tenth of a full turn, counterclockwise.
.demo { rotate: -0.1turn; }

x 60deg

Rotation around the horizontal axis. Without perspective, the element simply flattens.
.demo { rotate: x 60deg; }

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Rotate the arrows of expandable sections with rotate rather than swapping the icon. The transition then looks smooth.
  • The turn unit is easy to read in animations: 1turn is a full rotation.

Related entries

#

Spotted a mistake or missing an example? Write to us.