Quick Facts
- Category: Web Development
- Published: 2026-05-16 10:58:05
- How to Install and Use Fonttrio Font Pairings in Your shadcn/ui Project
- How to Build Your Second Brain in Claude Projects (A Step-by-Step Guide)
- Exploit Kits Surge in Q1 2026 Targeting Microsoft Office and OS Platforms
- Homebridge 2.0 Adds Matter Support: Expanding Apple Home Compatibility
- Kubernetes v1.36 Enhances Pod Resource Management with Beta In-Place Vertical Scaling
Introduction
The CSS rotateY() function lets you rotate an element around its vertical y‑axis, creating a horizontal flipping effect. It’s part of the transform property and is widely used to add depth and interactivity to web designs. Whether you’re building a 3D card flip or a subtle hover effect, understanding rotateY() is essential.

Imagine a pin stuck through the top center of an element: with rotateY(), the element can turn left or right as if it were a door swinging on its hinges. Positive values rotate the element to the right, negative values to the left.
.element {
transform: rotateY(45deg);
transition: transform 0.3s ease;
}This function is defined in the CSS Transforms Module Level 2 specification.
Syntax
rotateY() = rotateY( [ <angle> | <zero> ] )The function accepts a single argument of type <angle> (or the special value 0). This argument determines the rotation amount around the y‑axis.
Angle Units
The <angle> data type offers four units:
- deg (degrees): 1/360 of a full circle. Example:
90deg. - grad (gradians): 1/400 of a full circle. Example:
100grad. - rad (radians): Equivalent to approximately 57.3°. One radian equals 180°/π. Example:
1.57rad. - turn: 1 turn = 360°. Example:
0.5turn.
All units are interchangeable. For example, rotateY(180deg) and rotateY(0.5turn) produce the same visual result.
Rotation Direction
When the angle is positive, the element’s right edge moves away from the viewer, making it appear to rotate to the right. When negative, the left edge moves away, rotating the element to the left.
/* Examples */
rotateY(90deg); /* rotates right */
rotateY(-180deg); /* rotates left */
rotateY(1.57rad); /* approximately 90deg right */
rotateY(1turn); /* full rotation */Creating 3D Depth with perspective
For rotateY() to produce a true three‑dimensional effect, you must set the perspective property on the parent element. perspective mimics the viewer’s distance from the element, defining the strength of the 3D projection.
Without perspective, the rotation looks flat and shrunk—like a 2D image simply compressing. With perspective, the element gains depth, appearing to tilt in space.

.parent {
perspective: 800px;
}
.child {
transform: rotateY(60deg);
}Values between 400px and 1200px work well for most designs. Lower values (e.g., 200px) exaggerate the depth, while higher values (e.g., 2000px) make the effect subtle.
Practical Examples
3D Card Flip
A common use case is a card that flips over when hovered. By combining rotateY() with backface-visibility: hidden, you can hide the back side while the front rotates away and the back comes into view.
.card {
perspective: 1000px;
}
.card-inner {
transition: transform 0.6s;
transform-style: preserve-3d;
}
.card:hover .card-inner {
transform: rotateY(180deg);
}
.card-front, .card-back {
backface-visibility: hidden;
}
.card-back {
transform: rotateY(180deg);
}Interactive Hover Effects
You can also apply a mild rotation on hover to add a playful tilt:
img {
transition: transform 0.3s;
}
img:hover {
transform: rotateY(10deg);
}This works best when perspective is set on a parent container.
Browser Compatibility
The rotateY() function is supported in all modern browsers. For older versions (e.g., Internet Explorer 9 and below), you may need vendor prefixes like -webkit-transform and -ms-transform. Always test your implementation across target browsers.
Best Practices
- Always apply
perspectiveto a parent element when using 3D transforms. - Combine with
transitionfor smooth animations. - Use
transform-style: preserve-3dif you have nested 3D elements. - Avoid excessive rotation angles that may disorient users.
With rotateY(), you can unlock a new dimension of interactivity and visual richness. Experiment with different angles and perspectives to achieve the perfect 3D effect for your project.