CSS Portal

rotate() CSS Function

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

Description

The rotate() CSS function is a transformation function used to rotate an element around a fixed point on the 2D plane. This function is part of the broader transform property, which allows you to apply various visual transformations such as scaling, translating, and skewing to elements. By default, rotate() rotates the element around its origin point, which can be modified using the transform-origin property.

The value of rotate() is an angle, typically specified in degrees (deg), radians (rad), turns (turn), or gradians (grad). Positive angles rotate the element clockwise, while negative angles rotate it counterclockwise. For example, rotate(45deg) will turn an element 45 degrees clockwise.

A common use case is rotating div elements for decorative effects or interactive UI components. Combined with other functions like scale() or translate(), it enables complex visual animations.

Example:

.box {
  width: 100px;
  height: 100px;
  background-color: coral;
  transform: rotate(30deg);
}

In this example, the .box element is rotated 30 degrees clockwise around its center. Adjusting the transform-origin allows rotation around different points, such as a corner or a custom offset.

rotate() is particularly useful in animations, hover effects, and interactive graphics, making it a fundamental tool in modern web design.

Syntax

transform: rotate(<angle>);

Values

  • <angle>A positive value rotates the element clockwise, a negative value rotates the element counter clockwise.

Example

<div class="rotate-box">
Rotate Me!
</div>
/* The container for the element */
.rotate-box {
width: 100px;
height: 100px;
background-color: #3498db;
color: white;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;

/* The rotation property */
transform: rotate(45deg);

/* Optional: adds a smooth transition if you change the angle */
transition: transform 0.5s ease;

/* Centering the box for display purposes */
margin: 50px auto;
}

Browser Support

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

This function 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: 31st December 2025

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