CSS transform Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The transform property lets you translate, rotate, scale, or skew an element visually. It changes how the element is painted, not how much space it keeps in normal flow.

Any value other than none creates a stacking context. You can also use the individual properties translate, rotate, and scale, which run before transform.

Standard-track.

Baseline widely available for 2D transforms. Not deprecated as a property.

Accessibility motion

Animated scale/zoom can trigger discomfort. Respect prefers-reduced-motion when you animate transforms.

Applies to transformable elements.

Non-replaced inline boxes (plain span text) do not transform. Use a block or inline-block box instead.

CSS Syntax

syntax.css
transform: none | <transform-function>+ | initial | inherit;

List one or more functions separated by spaces. They apply left to right, and that order changes the result.

Property Values

ValueDescriptionTry it
noneNo transform (initial)Try it
translate(40px, 0)Move along X and YTry it
rotate(15deg)Rotate around the transform originTry it
scale(1.2)Grow or shrink from the originTry it
translate(20px) rotate(15deg)Combine functions (order matters)Try it
inheritTakes the parent’s transformTry it

Also common: skew(), matrix(), and 3D forms such as rotateY() / translate3d(). Start with 2D functions first.

How to Use transform

Pick the visual change you need, then stack functions only when one is not enough.

  1. Target a transformable box (div, button, img, or an inline-block).
  2. Choose a function: translate, rotate, scale, or skew.
  3. Combine with spaces when needed; test order if the result looks wrong.
  4. Tune the pivot with transform-origin.
GoalTypical value
Slide sidewaystranslateX(40px)
Tip / badge anglerotate(-8deg)
Hover growscale(1.05)
Resetnone

Live Preview

Same box. Change only transform. Layout space stays put.

The ghost outline shows the untransformed layout box.

Stage
Box

transform: translate(40px, 0)

CSS Examples

Each snippet focuses on transform. Use Try It Yourself for a live editor.

Example 1 — Move with translate

Slide the box 40px to the right without changing layout flow.

CSS
<style>
  .box {
    transform: translate(40px, 0);
  }
</style>

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

How It Works

  1. Keep the box in flow. No position change is required for a simple slide.
  2. Apply translate. The first argument is X; the second is Y (0 here).
  3. Layout stays. Following content still sees the original box position.
  4. Shorthand tip. translateX(40px) is the same horizontal move.

Example 2 — Rotate

Turn the box 15 degrees around its transform origin.

CSS
<style>
  .box {
    transform: rotate(15deg);
  }
</style>

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

How It Works

  1. Pick an angle. Positive degrees rotate clockwise in the default coordinate system.
  2. Pivot at the origin. Default origin is the center; change it with transform-origin.
  3. Corners may stick out. Neighbors can look overlapped even though flow is unchanged.
  4. Units. deg, turn, and rad are all valid.

Example 3 — Combine Translate and Rotate

Move first, then rotate—order changes the final spot.

CSS
<style>
  .box {
    transform: translate(20px) rotate(15deg);
  }
</style>

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

How It Works

  1. Write left to right. translate runs first, then rotate.
  2. New axes after each step. Later functions use the updated coordinate space.
  3. Swap to compare. rotate(15deg) translate(20px) lands in a different place.
  4. One declaration. A second transform rule would replace the first, not add to it.

Edge Cases & Pitfalls

If a transform looks wrong, one of these is usually why.

flow

Layout space does not move

Transformed paint can overlap neighbors, but margins and following boxes still use the original box. Use positioning or margins when you need real layout space.

order

Function order matters

translate then rotate is not the same as rotate then translate. Swap intentionally when debugging.

inline

Plain inline text will not transform

Non-replaced inline elements are not transformable. Set display: inline-block or use a block-level element.

stack

Non-none creates a stacking context

Absolute/fixed descendants are contained by a transformed ancestor. That can surprise you with overlays and modals.

replace

One transform replaces another

You cannot add a second transform declaration to stack more functions. Put every function in the same value, or use the individual translate / rotate / scale properties.

Browser Support

transform is a browser CSS property for visual transforms. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available since Sep 2015

transform

2D transforms: Chrome 4+, Firefox 3.5+, Safari 3.1+, Edge 12+, IE 9+. 3D transforms: modern evergreen browsers (Chrome 12+, Firefox 10+, Safari 4+, Edge 12+).

97% 2D transform support
Google Chrome 4+ (2D)
Full support
Mozilla Firefox 3.5+ (2D)
Full support
Apple Safari 3.1+ (2D)
Full support
Microsoft Edge 12+
Full support
Opera 10.5+ (2D)
Full support
Samsung Internet 1+
Full support
Internet Explorer 9+ (2D)
Partial / older 3D
transform Widely supported

Bottom line: Safe for everyday 2D translate, rotate, and scale. Prefer unprefixed modern syntax; vendor prefixes are no longer needed for current browsers.

Key Takeaways

  • Role: visual translate / rotate / scale / skew without changing flow space.
  • Initial value: none. Not inherited.
  • Order: functions apply left to right; swapping them changes the result.
  • Side effect: non-none creates a stacking context.

One line: use transform for visual motion and shape changes; keep layout spacing with margins or positioning when the gap must stay empty.

Frequently Asked Questions

It applies visual transforms such as translate, rotate, scale, and skew. The element keeps its original layout space; only the painted result moves.
none. No transformation is applied.
Yes. Space-separate them in one declaration, for example transform: translate(20px) rotate(15deg). Order matters.
No. Neighbors still lay out as if the element were untransformed. Overlap is common when you move or scale a lot.
translate, rotate, and scale are individual longhands applied before the transform property. transform can combine many functions in one value.
Baseline widely available for 2D transforms (Chrome 4+, Firefox 3.5+, Safari 3.1+, Edge 12+, IE 9+). 3D functions are also widely supported in modern browsers. It is a browser CSS property, not a Node.js feature.

Next: transform-origin

Learn how to change the pivot used by rotate and scale.

transform-origin tutorial →

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.

8 people found this page helpful