Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Transforms, Transitions and Animations

The translate property

Reference for the CSS translate property: move an element with its own property, independent of transform, with one, two or three values and easy animation.

The translate property moves an element along the x, y and optionally z axis, just like the translate() functions inside transform, but as a property of its own. That means you can set, override or animate the movement without repeating (or accidentally erasing) a rotate() or scale() that lives in transform.

Like all transforms, it does not affect layout: the element's original space stays reserved.

CSS
.card:hover {
  translate: 0 -4px;
}

Try it

translate with transition

Syntax

CSS
translate: none | <length-percentage> [ <length-percentage> <length>? ]?;
  • Initial value: none
  • Applies to: transformable elements
  • Inherited: no
  • Animatable: yes
  • Computed value: none, or a pair or triple with absolute lengths and percentages

Values

Value Description
One value Horizontal move; vertical is 0. translate: 20px equals translateX(20px).
Two values Horizontal and vertical move.
Three values Horizontal, vertical and depth (z). The third must be a length, not a percentage.
none No translation.

Percentages refer to the element's own width (x) and height (y).

Usage notes

  • Order of application. The individual properties apply in this order: translate, then rotate, then scale, then transform. A rotate set via the rotate property therefore happens after the move, unlike a list inside transform where order is yours to choose.
  • Easy hover effects. Because the property is separate, a :hover rule only needs translate: ... and does not have to copy the base transform.
  • Same side effects as transform. A non-none value creates a stacking context and a containing block for fixed and absolute descendants.
  • Centering trick. translate: -50% -50% after top: 50%; left: 50% still works for absolutely positioned elements, but grid or inset with margin: auto is often simpler.
  • Reduced motion. Large movements should respect prefers-reduced-motion.

Browser support

Individual transform properties are newer than transform. They are available in current versions of the major browsers, but check a compatibility table before relying on them for older ones.