# translate()

> The `translate()` CSS function moves an element from its current position along the X and Y axes.

## How do I move an element with translate() in CSS?

The function that moves an element from its current position along the X and Y axes. It can be used to adjust an element's position relative to its normal flow, creating effects like shifting or sliding.

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

## Example

Wrong:

```css
.toast {
  position: relative;
  left: -100%;
  transition: left 0.3s;
}
.toast.open {
  left: 0;
}
```

Right:

```css
.toast {
  transform: translate(-100%, 0);
  transition: transform 0.3s;
}
.toast.open {
  transform: translate(0, 0);
}
```

Animating `transform` skips layout on each frame, so the slide stays smooth.

## Common mistakes

- Expecting `translate(50%)` to move by half the parent's width, while it uses the element's own width.
- Expecting neighbors to fill the freed space, while translation doesn't affect layout.

## Key points

- Animated movement uses `translate()` instead of changing `top`, `left` or `margin`.
- Percentages in `translate()` are used as a share of the element's own size, not its parent.
- Hover states keep the other functions in the same `transform` list, or use the `translate` property.

## Interview questions

### What is the difference between translate() and the translate property?

`translate()` is a function inside `transform`; the `translate` property sets the same move on its own, so it doesn't override other transforms.

### What does translate() do with one value?

It moves the element only along the X axis; the Y offset is '0'.

## Related cards

- [translate](https://wonderium.dev/css/translate-property.md)
- [transform](https://wonderium.dev/css/transform.md)
- [translateX()](https://wonderium.dev/css/translate-x.md)
- [translateY()](https://wonderium.dev/css/translate-y.md)
- [Compositing](https://wonderium.dev/web/compositing.md)

---

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