rotateZ() CSS Function
Description
The rotateZ() CSS function is used to apply a 2D rotation to an element around its Z-axis, which is perpendicular to the screen. This function is part of the transform family of functions, allowing elements to be rotated, scaled, skewed, or translated. When you use rotateZ(), the element rotates in a clockwise or counterclockwise direction based on the angle value provided, typically in degrees (deg) or radians (rad). Positive values rotate the element clockwise, while negative values rotate it counterclockwise.
One of the main advantages of rotateZ() is its ability to combine with other transform functions like rotateX() and rotateY() for 3D effects, or with scale() and translate() for more complex transformations. It's commonly used for animations, hover effects, and interactive UI elements.
For example, you could rotate a div element 45 degrees around its center:
div {
transform: rotateZ(45deg);
transition: transform 0.5s ease;
}
This would smoothly rotate the element when the transform property changes, such as on hover:
div:hover {
transform: rotateZ(-45deg);
}
Using rotateZ() is particularly useful for 2D rotations without affecting the perspective or depth of an element, making it simpler than full 3D rotations when you only need planar movement.
Syntax
transform: rotateZ(<angle>);
Values
- <angle>A positive value rotates the element clockwise, a negative value rotates the element counter clockwise.
Example
Browser Support
The following information will show you the current browser support for the CSS rotateZ() 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
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
