CSS rotate Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The rotate property turns an element around its transform-origin. An angle alone rotates around the Z axis (flat on the screen). You can also rotate around x, y, z, or a custom 3D vector.

It is an individual transform property, like translate and scale. That lets you change rotation without rewriting a full transform list. The initial value is none. It is not inherited and creates a stacking context when not none.

Baseline · Widely available.

Not deprecated. Supported in modern browsers since about 2022. For very old browsers, fall back to transform: rotate(…).

CSS Syntax

syntax.css
rotate: none | <angle> | x|y|z <angle> | <number>{3} <angle>;

Example: rotate: 45deg; or rotate: y 180deg;. Positive 2D angles turn clockwise.

Property Values

ValueDescriptionTry it
noneNo rotation. Initial valueTry it
<angle>2D rotation around Z (for example 45deg, 0.25turn)Try it
x / y / z + angle3D rotation around that axisTry it
vector + angleThree numbers plus an angle (like rotate3d())Try it
initial / inheritReset to none, or copy from the parentTry it

How to Use rotate

Pick an angle (and optional axis), then adjust the pivot if the turn looks wrong.

  1. Choose the element to turn (any transformable box).
  2. Set rotate to an angle, or an axis plus angle.
  3. Change transform-origin if you need a different pivot.
  4. Optional: pair with transition for hover motion — respect prefers-reduced-motion when animating.
PieceRequired?Role
Angle or noneYesHow far to turn (or turn nothing)
Axis / vectorOptionalDefaults to Z for a plain angle
transform-originOptionalWhere the pivot point sits
Fixed apply order—Always translate → rotate → scale → transform

Live Preview

Change rotate on the sample box. The dashed frame is the original layout space.

Axis values need a bit of perspective to look 3D. Layout size of the box does not change.

Box
Rotate

rotate: 45deg

CSS Examples

Each snippet focuses on rotate. Extra styles stay minimal for study. Use Try It Yourself for a live editor.

Example 1 — Simple Angle

Turn a box 45 degrees around its center (default origin).

CSS
<style>
    .box {
    rotate: 45deg;
    background: #2563eb;
    color: #fff;
    padding: 16px;
    width: 80px;
    text-align: center;
  }
</style>

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

How It Works

  1. Set an angle. rotate: 45deg turns the box around the Z axis.
  2. Clockwise positive. In CSS, a positive angle rotates clockwise on screen.
  3. Default pivot is center. Without changing origin, the middle of the box stays put.
  4. Layout box stays. The element still occupies its original space for layout.

Example 2 — Change the Pivot

Rotate from the top-left corner instead of the center.

CSS
<style>
    .box {
    rotate: 30deg;
    transform-origin: top left;
    background: #2563eb;
    color: #fff;
    padding: 16px;
    width: 80px;
    text-align: center;
  }
</style>

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

How It Works

  1. Keep a rotation. rotate: 30deg still turns the box.
  2. Move the origin. transform-origin: top left sets the pivot to the top-left corner.
  3. Same angle, different swing. The box now arcs around that corner.
  4. Origin is separate. It is not part of the rotate value — set it on its own.

Example 3 — Hover Rotate

Animate rotation on hover with a short transition.

CSS
<style>
  button {
    rotate: 0deg;
    transition: rotate 0.25s ease;
    background: #2563eb;
    color: #fff;
    border: 0;
    padding: 12px 16px;
  }
  button:hover {
    rotate: 15deg;
  }
</style>

<button type="button">Hover me</button>
Try It Yourself

How It Works

  1. Start at identity. rotate: 0deg keeps a stacking context stable before hover.
  2. Transition only rotate. transition: rotate 0.25s ease animates that property.
  3. Change on hover. rotate: 15deg tilts the button slightly.
  4. Why individual helps. You did not need to rewrite a full transform list.

Edge Cases & Pitfalls

If the spin looks wrong, one of these is usually why.

order

Fixed apply order with translate / scale

Individual transforms always run as translate → rotate → scale → transform. Need a different order? Use transform functions instead.

origin

Wrong pivot point

Rotation swings around transform-origin. Change it when the element turns from the wrong spot.

stack

Creates a stacking context

A non-none rotate creates a stacking context. Prefer rotate: 0deg in the base state if hover would otherwise change stacking suddenly.

3d

Axis rotations need perspective

rotate: x … / y … look flat without perspective (or a 3D context) on an ancestor.

fallback

Older browsers need transform

IE and pre-2022 engines lack rotate. Use transform: rotate(45deg) (or @supports) when you must support them.

Browser Support

rotate is a browser CSS property for individual transforms. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

rotate

Chrome 104+, Edge 104+, Firefox 72+, Safari 14.1+ / iOS 14.5+. Not supported in Internet Explorer.

96% Global support
Google Chrome 104+
Full support
Mozilla Firefox 72+
Full support
Apple Safari 14.1+
Full support
Microsoft Edge 104+
Full support
Opera 90+
Full support
Samsung Internet 20+
Full support
Internet Explorer No support
No support
rotate Widely supported

Bottom line: Safe for modern sites. Fall back to transform: rotate() for older browsers. This is not a JavaScript runtime API.

Key Takeaways

  • Role: rotate independently of the transform list — angle, axis, or vector.
  • Initial: none. Positive 2D angles turn clockwise.
  • Order: translate → rotate → scale → transform.
  • Pivot: control the turn point with transform-origin.

One line: rotate turns the painted box — without rewriting the whole transform stack.

Frequently Asked Questions

It rotates an element around its transform origin without using the transform shorthand. An angle alone rotates around the Z axis. You can also rotate around x, y, z, or a custom 3D vector.
Both turn the element. rotate is an individual transform property you can set and animate on its own. transform: rotate() is a function inside the older transform list and must be rewritten with any other transform functions you keep.
The initial value is none, which means no rotation. Visually that matches 0deg.
No. It changes how the element is painted. The original layout box usually stays the same, so neighbors do not reflow.
Individual transform properties always run in a fixed order: translate, then rotate, then scale, then any transform property last — regardless of source order in your CSS.
It is Baseline Widely available: Chrome 104+, Edge 104+, Firefox 72+, Safari 14.1+. It is a browser CSS property, not a Node.js feature. Prefer transform: rotate() only if you must support older browsers.

Next: row-gap

Set the gap between rows in flex and grid layouts.

row-gap tutorial →

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.

8 people found this page helpful