CSS Portal

CSS rotate Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The rotate property exposes rotation as a first-class transform on an element, letting authors apply a rotational transform independently of other transform functions. Where traditionally authors combined rotations with scales and translations using the composite transform shorthand, rotate isolates rotation so it can be authored, overridden, or animated separately and more declaratively. Conceptually it rotates the element’s visual rendering in its local coordinate space, affecting only the painted representation rather than the element’s layout box.

The pivot point for that rotation is determined by the element’s transform origin, which controls the point around which the visual rotation occurs and therefore strongly influences the motion and final placement of rotated content. Use of transform-origin lets you change whether an element spins around its center, a corner, or any specified anchor, which is essential for creating natural-looking rotations (for example, a door swinging on a hinge versus a wheel turning). Because rotation operates on the visual output, the document flow and surrounding layout remain based on the element’s original unrotated box.

Rotation changes can affect stacking, compositing, and interaction in ways worth considering: any non-identity transform typically promotes the element to its own composite layer and can create a new stacking context, which impacts how it is painted relative to siblings and may improve or worsen performance depending on frequency of updates. For smooth changes, authors commonly pair rotate with CSS animation primitives such as transition or animation, and may use will-change to hint the browser about upcoming changes. Hit-testing and pointer events follow the transformed geometry, so rotated elements respond to input where they are visually rendered rather than at their original axis-aligned box.

In practice, rotate is a powerful tool for micro-interactions, iconography, and complex UI motion because it keeps rotation semantics clear and composable. Designers should be mindful of legibility and accessibility: heavy or unexpected rotation of text and controls can confuse users and assistive technologies, so use rotation sparingly for decorative or clearly-signposted effects. When combining rotations with other visual transforms, think in terms of separate transform layers and the visual stacking they produce to avoid surprises in rendering and interaction.

Definition

Initial value
none
Applies to
transformable elements
Inherited
no
Computed value
as specified
Animatable
a transform
JavaScript syntax
object.style.rotate

Interactive Demo

1
2
3
4
5
6

Syntax

rotate: none | axis | angle | vector angle

Values

  • noneSpecifies that no rotation should be applied.
  • axisOptional. If not set, z-axis is default. Defines axis to rotate element around. Possible values: x, y, z
  • angleDefines how much an element is rotated. Possible units: deg, rad, turn
  • vector angleThree numbers define a vector for the element to be rotated around. The numbers are x-, y- and z-coordinates for the vector, respectively. The last value is the angle for how much to rotate. Possible values: number, number, number, angle

Example

<div class="container">
<h1>CSS rotate examples</h1>
<div class="demo">
<div class="box box--static">Static<br>rotate(25deg)</div>
<div class="box box--hover">Hover me<br>rotate(45deg)</div>
<div class="box box--spin">Spinning<br>animation</div>
</div>
</div>
/* Basic page layout */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: #f5f7fa;
  color: #222;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  padding: 24px;
}

.container {
  width: 720px;
  max-width: 100%;
}

h1 {
  font-size: 18px;
  margin: 0 0 16px 0;
}

.demo {
  display: flex;
  gap: 16px;
  align-items: center;
}

/* Common box styles */
.box {
  width: 140px;
  height: 100px;
  background: linear-gradient(135deg, #7b61ff 0%, #4ecdc4 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(33, 33, 33, 0.12);
  font-weight: 600;
  line-height: 1.1;
}

/* 1) Static rotation using transform: rotate(angle) */
.box--static {
  transform: rotate(25deg); /* rotated clockwise 25 degrees */
}

/* 2) Rotate on hover with a smooth transition */
.box--hover {
  transition: transform 260ms cubic-bezier(.2,.9,.2,1);
  transform-origin: center; /* rotate around the center */
}

.box--hover:hover {
  transform: rotate(45deg); /* rotate when hovered */
}

/* 3) Continuous rotation using keyframes */
.box--spin {
  animation: spin 2s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

Browser Support

The following information will show you the current browser support for the CSS rotate property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!