CSS translate Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Transforms

What You’ll Learn

The translate property moves an element horizontally, vertically, or in 3D — without changing its place in the document flow. It is ideal for hover lifts, badges, and centering overlays.

01

Move X/Y

Shift position.

02

Units

px, %, rem.

03

No layout shift

Visual only.

04

Hover lift

UI micro-motion.

05

Centering

-50% pattern.

06

vs transform

Standalone prop.

Introduction

The translate property in CSS is used to move an element from its current position, both horizontally and vertically. It is part of the CSS transform family, which allows developers to manipulate elements in 2D and 3D space without affecting the layout of the document.

Definition and Usage

Use translate when you need to reposition an element visually — for example, nudging a badge, lifting a card on hover, or centering a modal. Pair it with transition for smooth animated movement.

💡
Beginner Tip

You may also see transform: translate(50px, 20px) in older examples. The standalone translate property does the same kind of movement and is easier to animate independently.

📝 Syntax

The syntax for the translate property is as follows:

syntax.css
element {
  translate: tx ty tz;
}
  • tx — horizontal translation (X axis)
  • ty — vertical translation (Y axis)
  • tz — optional depth translation (Z axis) for 3D

Basic Example

translate.css
.box {
  translate: 50px 20px;
}

Syntax Rules

  • One value sets X only; two values set X and Y; three values add Z.
  • Length units include px, em, rem, and %.
  • Percentages are relative to the element’s own size (border box).
  • Default is none (no movement).
  • The property is not inherited.

Related Properties

  • transform — shorthand that can include translate(), rotate(), scale()
  • rotate — standalone rotation property
  • scale — standalone scaling property
  • transition — animate translate changes smoothly
  • transform-origin — pivot point for transforms

🎯 Default Value

The default value is none, which means no translation — the element stays in its original visual position.

⚡ Quick Reference

QuestionAnswer
Default valuenone
Move right and downtranslate: 50px 20px;
Move horizontally onlytranslate: 40px;
Center overlaytranslate: -50% -50%;
Hover lifttranslate: 0 -8px;
InheritedNo

💎 Property Values

The translate property accepts length and percentage values.

ValueExampleDescription
nonetranslate: none;No translation is applied.
txtranslate: 50px;A length value (px, em, rem, %, etc.) specifying the horizontal translation.
tytranslate: 0 20px;A length value specifying the vertical translation when two values are provided.
tztranslate: 0 0 10px;Optional third value for depth along the Z axis in 3D contexts.
50px 20px 40px 0 0 -8px -50% -50%

When to Use translate

translate is ideal for visual repositioning without changing layout:

  • Hover lifts — Move cards or buttons slightly on hover with translate: 0 -8px.
  • Badges and labels — Nudge small elements relative to text or icons.
  • Centering overlays — Combine with top: 50%; left: 50% and translate: -50% -50%.
  • Slide-in panels — Animate from off-screen with transitions on translate values.

👀 Live Preview

The dashed box shows the original space; the blue box is shifted with translate: 36px 12px:

Visual shift, layout unchanged

Examples Gallery

In this example, we’ll translate a div element horizontally and vertically using the translate property.

📜 Core Patterns

Move elements with one or two translate values on the X and Y axes.

Example 1 — Basic horizontal and vertical move

In this example, we’ll translate a div element horizontally and vertically using the translate property.

index.html
<style>
  .box {
    width: 100px;
    height: 100px;
    background-color: #3498db;
    translate: 50px 20px;
  }
</style>

<div class="box"></div>
Try It Yourself

How It Works

50px moves the box right; 20px moves it down. The original layout space is preserved.

Example 2 — X-only, Y-only, and combined

One value moves horizontally; two values control X and Y independently.

axes.css
.x { translate: 40px 0; }
.y { translate: 0 30px; }
.xy { translate: 30px 20px; }
Try It Yourself

How It Works

Setting 0 on an axis keeps that axis unchanged while the other axis moves.

📄 UI Patterns

Combine translate with transitions and positioning for common UI effects.

Example 3 — Hover lift with transition

Move a card upward on hover and animate the change smoothly.

hover.css
.card {
  translate: 0 0;
  transition: translate 0.25s ease;
}

.card:hover {
  translate: 0 -8px;
}
Try It Yourself

How It Works

Negative Y values move elements up. Transitioning translate directly is cleaner than animating top or margin.

Example 4 — Center a modal with translate

Use top: 50%; left: 50% with translate: -50% -50% to center an absolutely positioned box.

center.css
.modal {
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
}
Try It Yourself

How It Works

Positioning places the top-left corner at the center; translate: -50% -50% pulls the box back by half its own width and height.

♿ Accessibility

  • Do not hide content off-screen — Translating elements out of view can remove them from sight but they may still receive focus.
  • Reduced motion — Disable or reduce translate animations when prefers-reduced-motion: reduce is set.
  • Keyboard users — Ensure hover-only translate effects have equivalent focus-visible styles.
  • Screen readers — translate is visual only; do not rely on it to convey semantic state changes.

translate + transition

Animate translate for smooth hover lifts and slide effects. It performs better than animating top, left, or margin because it does not trigger layout reflow.

translate-transition.css
.btn {
  translate: 0 0;
  transition: translate 0.2s ease;
}
.btn:hover {
  translate: 0 -2px;
}

🧠 How translate Works

1

Element renders in layout

The browser places the element in normal document flow.

Layout
2

translate is applied

X, Y, and optional Z values shift the painted appearance.

Transform
3

Layout space stays put

Sibling elements behave as if the box were not moved.

No reflow
=

Visual repositioning

The element appears moved without disrupting page layout.

Browser Compatibility

The translate property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It is part of the CSS transform module, which has excellent support across all major browsers.

Modern browsers · Widely supported

Standalone translate property

The individual translate property works in current Chrome, Firefox, Safari, and Edge. Older code may use transform: translate() instead.

96% Browser support
Google Chrome 104+ · Desktop & Mobile
Full support
Mozilla Firefox 72+ · Desktop & Mobile
Full support
Apple Safari 14.1+ · macOS & iOS
Full support
Microsoft Edge 104+ · All versions
Full support
Opera 90+ · All versions
Full support

Testing tip

For very old browsers, fall back to transform: translate(). The visual result is the same; only the property name differs.

translate property 96% supported

Bottom line: translate is reliable in modern browsers; use transform: translate() as a fallback if needed.

Conclusion

The translate property is essential for creating smooth and interactive web experiences by moving elements dynamically on the page.

It is widely supported and offers a straightforward way to manipulate the position of elements without affecting their layout properties. Experiment with different values for tx and ty to achieve the desired visual effects in your web projects.

💡 Best Practices

✅ Do

  • Use translate instead of top/left for animated movement
  • Pair with transition for smooth hover effects
  • Use -50% -50% for centering positioned overlays
  • Prefer small pixel values for subtle UI feedback
  • Respect prefers-reduced-motion: reduce

❌ Don’t

  • Use translate to fix layout problems — use flexbox or grid instead
  • Assume translated content is removed from the accessibility tree
  • Move critical information far off-screen with translate
  • Forget that layout space is unchanged after translating

Key Takeaways

Knowledge Unlocked

Five things to remember about translate

Use these points when moving elements with CSS.

5
Core concepts
🕐 02

none

Default value.

Default
📚 03

No reflow

Layout stays.

Behavior
📈 04

Percentages

Center pattern.

Values
05

+ transition

Smooth motion.

Pattern

❓ Frequently Asked Questions

translate moves an element from its normal position along the X, Y, and optionally Z axes without changing document flow.
The default is none, which means no translation is applied.
translate is a standalone property for movement only. transform: translate() is a function inside the transform shorthand that can be combined with rotate, scale, and other functions.
No. translate creates a visual shift only. The element still occupies its original layout space.
No, translate is not inherited. Each element sets its own translation.

Practice in the Live Editor

Open the HTML editor and experiment with translate values on boxes and cards.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful