Interaction & Visual Craft

CSS translate3d() Still Wins on Depth — and Its Oldest Trick Is Now Obsolete

translate3d() moves elements in 3D space per CSS Transforms Level 2, forces GPU compositing, and needs a parent perspective value — typically 400px–900px — for Z-axis motion to render at all.

  • AuthorPriya Raman
  • ChannelInteraction & Visual Craft
  • Filed
  • Read3 min
CSS translate3d() Still Wins on Depth — and Its Oldest Trick Is Now Obsolete
AI-generated
  • translate3d() is defined in CSS Transforms Module Level 2, currently Editor's Draft
  • Recommended perspective range for depth effects is 400px–900px
  • The tz argument accepts only length values; percentages are invalid
  • translate3d(0,0,0) forces GPU compositing but modern browsers often make will-change: transform the better choice
  • The function is fully supported across all modern browsers

The CSS translate3d() function moves an element along the X, Y, and Z axes in three-dimensional space, and it is defined in the CSS Transforms Module Level 2 specification — currently in Editor's Draft, meaning details can still change before it becomes a Candidate Recommendation. It is the 3D counterpart to translate(), and the best tool when you want depth.

The syntax takes three arguments:

transform: translate3d(tx, ty, tz);
  • tx moves the element horizontally. Positive values shift it right, negative values left. It accepts <length> or <percentage>, with percentages relative to the element's own width.
  • ty moves it vertically. Positive goes down, negative goes up. Percentages here resolve against the element's height.
  • tz moves it in depth. Positive values pull the element closer to the viewer; negative values push it away. This argument accepts <length> only — percentages are invalid because, as the specification's own logic goes, there is no depth to calculate a percentage of.

Arguments can mix units freely: translate3d(2rem, 1em, 100px) is valid, as is translate3d(50%, -50%, 0).

Why do developers reach for it?

When you need movement on only one or two axes, shorthands exist. translate3d(50px, 0, 0) equals translateX(50px); translate3d(0, 30px, 0) equals translateY(30px); translate3d(0, 0, 100px) equals translateZ(100px).

So why write the three-axis version at all? Because it forces the browser to composite the element on the GPU, which — when the hardware path is available — improves animation performance. That single mechanical difference explains why you will find translate3d(50px, 0, 0) in older codebases instead of the shorter, equivalent translateX(50px).

What does moving along Z actually do?

Nothing, on its own. That is the part the documentation is blunt about: a bare transform: translate3d(0, 0, 100px) has no visible effect. You must set the perspective property on the element's parent, which then acts as the container the element transforms within:

.parent { perspective: 600px; }
.parent .element { transform: translate3d(0, 0, 100px); /* now visibly closer */ }

Perspective is the distance between your eye and the screen. A small value like 200px produces an intense, fisheye-like effect. A large value like 1200px gives subtle, refined depth. The typically recommended range is 400px–900px, though the source is candid that you sometimes have to play with values to get things right.

The classic use case is staggered depth — parallax and card flips. Three cards at different Z positions read as layered: a front card at translate3d(0, 0, 80px), a middle at 0, a back at -100px, all under a parent with perspective: 800px.

Is the zero-value hack still worth it?

You will see this in legacy CSS and it looks like a bug:

.animated-element { transform: translate3d(0, 0, 0); }

Nothing moves. The element does get promoted to its own composite layer, which makes animation smoother — the developer is effectively telling the browser to give the element its own separate layer. The catch: modern browsers are smart enough that this trick is barely necessary anymore, and will-change: transform often suffices. Overusing it wastes memory. The honest advice is to reach for it only when an actual jank problem shows up, not preemptively.

What about chaining transforms?

translate3d() becomes most powerful when chained with rotate3d() or scale3d() — but order matters, because transform functions render right-to-left. translate3d(0, 0, 100px) rotateY(45deg) rotates first, then translates in the rotated space. rotateY(45deg) translate3d(0, 0, 100px) translates first, then rotates around the original origin. Turning then stepping forward is not the same as stepping forward then turning.

Browser support is unqualified: translate3d() works across all modern browsers. What remains in flux is only the specification text — with Transforms Level 2 still in Editor's Draft, authors should expect the details, not the function itself, to shift.

Original: drafts.csswg.org

More from Priya Raman

Priya Raman

Show full bio

Market editor covering technology and product news in Product and interaction design, design systems at Interface Wire.

180 articles

Related articles

« Previous article