CSS transform Property

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

What You’ll Learn

The transform property moves, rotates, scales, and skews elements visually — a core tool for modern UI effects and animations.

01

translate

Move X/Y.

02

rotate

Turn angles.

03

scale

Resize.

04

skew

Slant shape.

05

Combine

Stack functions.

06

2D / 3D

Depth effects.

Introduction

The transform property in CSS is a powerful tool that allows web developers to apply 2D and 3D transformations to elements. This includes operations like translating (moving), rotating, scaling, and skewing elements.

The transform property is essential for creating dynamic and interactive designs without the need for complex animations or JavaScript.

Definition and Usage

Use transform for hover effects, card lifts, icon rotations, image galleries, and CSS transitions. Pair it with transition for smooth animated changes.

💡
Beginner Tip

Transforms change appearance only — the element keeps its original space in the layout. Use transform: translate() instead of changing top or left when you want smoother animations.

📝 Syntax

The syntax for the transform property is straightforward and can include multiple transformation functions.

syntax.css
element {
  transform: transformation-function transformation-function ...;
}

Here, transformation-function can be one or more of the following functions: translate(), rotate(), scale(), skew(), matrix(), perspective(), translateX(), translateY(), scaleX(), scaleY(), rotateX(), rotateY(), rotateZ(), and more.

Basic Example

transform.css
.box {
  transform: rotate(45deg);
}

Syntax Rules

  • Separate multiple functions with spaces; they apply right to left in the transform list.
  • Use units like px, %, or deg inside functions.
  • none removes all transforms.
  • 3D functions like rotateX() need perspective on a parent for visible depth.
  • The property is not inherited.

Related Properties

  • transform-origin — sets the pivot point for transforms
  • transition — animates transform changes smoothly
  • perspective — adds 3D depth to child transforms
  • will-change: transform — hints the browser to optimize animations

🎯 Default Value

The default value of the transform property is none, which means no transformation is applied to the element.

⚡ Quick Reference

QuestionAnswer
Default valuenone
Rotate 45 degreestransform: rotate(45deg);
Move right and downtransform: translate(20px, 10px);
Scale to 150%transform: scale(1.5);
Combine transformstransform: translateY(-4px) scale(1.02);
InheritedNo

💎 Property Values

The transform property accepts none or one or more transform functions.

ValueExampleDescription
nonetransform: none;No transformation is applied.
matrix(a, b, c, d, e, f)transform: matrix(1, 0, 0, 1, 0, 0);Defines a 2D transformation using a matrix of six values.
translate(tx, ty)transform: translate(10px, 20px);Moves the element by tx to the right and ty down.
translateX(tx)transform: translateX(10px);Moves the element horizontally.
translateY(ty)transform: translateY(10px);Moves the element vertically.
scale(sx, sy)transform: scale(1.2, 0.8);Scales the element horizontally and vertically.
scaleX(sx)transform: scaleX(1.5);Scales the element horizontally.
scaleY(sy)transform: scaleY(0.5);Scales the element vertically.
rotate(angle)transform: rotate(45deg);Rotates the element by the specified angle.
skew(ax, ay)transform: skew(10deg, 5deg);Skews the element horizontally and vertically.
skewX(ax)transform: skewX(15deg);Skews the element horizontally.
skewY(ay)transform: skewY(10deg);Skews the element vertically.
perspective(n)transform: perspective(500px);Defines a perspective view for 3D transformations.
translate() rotate() scale() skew() matrix()

When to Use transform

transform is ideal for visual effects that should feel smooth and performant:

  • Hover interactions — Lift cards with translateY() and scale()
  • Icon animations — Rotate chevrons or loading spinners with rotate()
  • Image galleries — Zoom thumbnails on hover using scale()
  • CSS transitions — Animate transform changes instead of layout properties

👀 Live Preview

Three boxes with different transform functions applied:

rotate(45deg)
scale(1.25)
translate(12px, 8px)

Examples Gallery

In this example, we’ll apply a simple rotation to a div element.

📜 Basic Transforms

Start with single-function transforms on a simple box.

Example 1 — Rotate a box 45 degrees

In this example, we’ll apply a simple rotation to a div element.

index.html
<style>
  .box {
    width: 100px;
    height: 100px;
    background-color: lightblue;
    transform: rotate(45deg);
  }
</style>

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

How It Works

The box rotates 45 degrees clockwise around its default transform origin (center).

Example 2 — Move with translate

Shift an element without affecting surrounding layout space.

translate.css
.badge {
  transform: translate(20px, -10px);
}
Try It Yourself

How It Works

translate(20px, -10px) moves the badge 20px right and 10px up from its normal position.

📄 UI Effects

Scale and combine transforms for interactive design patterns.

Example 3 — Scale on hover

Enlarge a card slightly when the user hovers, paired with a smooth transition.

scale.css
.card {
  transition: transform 0.2s ease;
}

.card:hover {
  transform: scale(1.05);
}
Try It Yourself

How It Works

scale(1.05) grows the card to 105% size. The transition makes the change smooth on hover.

Example 4 — Combined translate and rotate

Stack multiple transform functions in one declaration for richer effects.

combined.css
.tile {
  transform: translateY(-8px) rotate(-3deg);
}
Try It Yourself

How It Works

The tile lifts up 8px and tilts slightly, creating a playful “picked up” card effect.

♿ Accessibility

  • Respect reduced motion — Use @media (prefers-reduced-motion: reduce) to disable or simplify transform animations.
  • Do not rely on transform alone — Important state changes should also be clear in color, text, or ARIA attributes.
  • Avoid disorienting spins — Large continuous rotations can cause discomfort for some users.
  • Keep hit targets usable — Scaled elements may look larger but their click area may not change unless padded.

transform + transition

Transforms animate smoothly with CSS transitions. Prefer transforming over changing width, height, or top for better performance.

transition-transform.css
.btn {
  transition: transform 0.15s ease;
}
.btn:active {
  transform: scale(0.97);
}

🧠 How transform Works

1

Element is rendered

The browser lays out the element in normal document flow first.

Layout
2

Transform functions apply

CSS applies translate, rotate, scale, or skew on a visual layer.

Transform
3

Painted result appears

Users see the transformed shape while layout space stays unchanged.

Visual
=

Dynamic UI effects

Elements move, spin, and scale without rewriting HTML structure.

Browser Compatibility

The transform property is well-supported in most modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It is recommended to test your transformations across different browsers to ensure a consistent user experience.

Universal · All modern browsers

GPU-friendly effects

2D transforms work everywhere. 3D transforms are supported in all current major browsers with proper prefixes no longer required.

99% Browser support
Google Chrome 36+ · Desktop & Mobile
Full support
Mozilla Firefox 16+ · Desktop & Mobile
Full support
Apple Safari 9+ · macOS & iOS
Full support
Microsoft Edge 12+ · All versions
Full support
Opera 23+ · All versions
Full support

Testing tip

Test combined transforms and transform-origin in Safari and Firefox when building 3D card flips.

transform property 99% supported

Bottom line: transform is safe for production UI effects in all modern browsers.

Conclusion

The transform property is an essential tool for web developers looking to create visually engaging and interactive elements on their websites.

By leveraging various transformation functions, you can easily manipulate elements in both 2D and 3D space, adding a dynamic touch to your designs. Experiment with different transformations to see how this property can enhance the interactivity and visual appeal of your web projects.

💡 Best Practices

✅ Do

  • Use transform with transition for smooth hover effects
  • Prefer translate over changing top/left for animations
  • Set transform-origin when rotating from a corner
  • Honor prefers-reduced-motion for accessibility
  • Combine functions sparingly for readable CSS

❌ Don’t

  • Expect transforms to change document flow spacing
  • Overuse 3D transforms without testing performance on mobile
  • Rotate or skew large blocks of body text
  • Forget that function order matters in combined transforms

Key Takeaways

Knowledge Unlocked

Five things to remember about transform

Use these points when adding visual effects with CSS transforms.

5
Core concepts
02

none

Default value.

Default
🔄 03

rotate()

Turn elements.

Function
04

translate()

Move X/Y.

Function
🔗 05

Combine

Stack functions.

Pattern

❓ Frequently Asked Questions

transform applies 2D or 3D visual transformations such as translate, rotate, scale, and skew to an element without changing document flow.
The default is none, meaning no transformation is applied.
Yes. List multiple functions in one transform declaration, such as transform: translate(10px, 20px) rotate(15deg).
Transforms create a visual change only. The element still occupies its original layout space unless you also change positioning or margins.
No, transform is not inherited. Each element sets its own transformation.

Practice in the Live Editor

Open the HTML editor and try rotate, translate, and scale on a colored box.

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