# rotateY()

> The `rotateY()` CSS function rotates an element around the Y-axis.

## How do I make a flip card with rotateY() in CSS?

The function that applies a 3D rotation to an element around the Y-axis. This transformation swivels the element left or right, making it appear as though the element is rotating around a vertical line running from top to bottom.

- Topic: Transformations
- Type: function
- Browser support: Chrome 12+, Chrome Android 18+, Edge 12+, Firefox 10+, Firefox Android 10+, Safari 4+, Safari iOS 3.2+

## Example

Wrong:

```css
.front,
.back {
  position: absolute;
  inset: 0;
}
.back {
  transform: rotateY(180deg);
}
```

Right:

```css
.front,
.back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}
.back {
  transform: rotateY(180deg);
}
```

`backface-visibility: hidden` hides each face when it turns away, so only one side shows at a time.

## Common mistakes

- The back of the card shows mirrored front text.
- The flip works only with a mouse, never on touch or keyboard.

## Key points

- The back face is pre-rotated with `rotateY(180deg)` and both faces have `backface-visibility: hidden`.
- A `perspective` is set on the container of the flipping element.
- The flip also works on keyboard focus, not only on `:hover`.

## Interview questions

### Does rotateY() work without perspective?

It works, but looks flat: the element only gets narrower while turning, with no 3D depth.

### Why do my flip card faces flicker?

Usually `transform-style: preserve-3d` is missing on the rotating parent, so the faces are flattened into one plane.

## Related cards

- [rotateX()](https://wonderium.dev/css/rotate-x.md)
- [backface-visibility](https://wonderium.dev/css/backface-visibility.md)
- [perspective](https://wonderium.dev/css/perspective-property.md)
- [transform-style](https://wonderium.dev/css/transform-style.md)
- [:focus-within](https://wonderium.dev/css/focus-within.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/rotate-y
- Last updated: 2026-11-25
