Favorites

CSS <transform-function> Data Type

<transform-function>
CSS Data TypeThis data type is supported by all modern browsers.
Updated 21st November 2026

The <transform-function> data type is one transformation, such as translate(), rotate(), scale(), skew() or matrix(), used by the transform property.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The <transform-function> CSS data type represents a single transformation that changes the appearance of an element: moving, rotating, scaling, skewing or applying perspective. One or more transform functions, separated by spaces, form the value of the transform property. Transforms change only how an element is drawn; the space it takes up in the layout stays the same.

The functions fall into groups. Translation functions move an element: translate(), translateX(), translateY(), translateZ() and translate3d(). Rotation functions turn it: rotate(), rotateX(), rotateY(), rotateZ() and rotate3d(). Scaling functions resize it: scale(), scaleX(), scaleY(), scaleZ() and scale3d(). Skew functions slant it: skew(), skewX() and skewY(). Finally, matrix() and matrix3d() describe any transformation as numbers, and perspective() adds 3D depth.

The order matters: functions are applied from left to right, each one in the coordinate system produced by the previous ones. translateX(100px) rotate(45deg) moves the element and then turns it in place, while rotate(45deg) translateX(100px) turns it first and then moves it along the rotated axis, ending up somewhere else. Transforms are applied around the point set by transform-origin, which defaults to the centre. For single transformations, the individual translate, rotate and scale properties are often simpler.

Examples:

.card:hover {
  transform: translateY(-4px) scale(1.02);
}

.badge {
  transform: rotate(-8deg);
}

.flip {
  transform: perspective(600px) rotateY(180deg);
}

Interactive Demo

Transform
Demo Code
HTML Code
<div class="demo-area">
	<div class="demo-ghost"></div>
	<div class="demo-element">Transform</div>
</div>
CSS Code
.demo-area {
	position: relative;
	width: 300px;
	height: 190px;
	background: #f4f4f4;
	outline: 1px dashed #b0b0b0;
}
.demo-ghost, .demo-element {
	position: absolute;
	left: 100px;
	top: 55px;
	width: 100px;
	height: 80px;
	box-sizing: border-box;
}
.demo-ghost {
	border: 2px dashed #b0b0b0;
}
.demo-element {
	display: grid;
	place-items: center;
	background: rgb(247 37 133 / 85%);
	color: #fff;
	font-size: 14px;
	font-weight: bold;
	transform: translateX(60px);
}

Syntax

<transform-function> = <matrix()> | <matrix3d()> | <perspective()>
  | <rotate()> | <rotate3d()> | <rotateX()> | <rotateY()> | <rotateZ()>
  | <scale()> | <scale3d()> | <scaleX()> | <scaleY()> | <scaleZ()>
  | <skew()> | <skewX()> | <skewY()>
  | <translate()> | <translate3d()> | <translateX()> | <translateY()> | <translateZ()>

Values

  • translate(), translateX(), translateY(), translateZ(), translate3d()Move the element along one or more axes, by <length-percentage> values (translateZ and the z value of translate3d take only lengths).
  • rotate(), rotateX(), rotateY(), rotateZ(), rotate3d()Turn the element by an <angle> around an axis.
  • scale(), scaleX(), scaleY(), scaleZ(), scale3d()Resize the element by <number> or <percentage> factors. Negative values mirror it.
  • skew(), skewX(), skewY()Slant the element by an <angle> along one or both axes.
  • matrix(), matrix3d()Describe a 2D or 3D transformation directly as a matrix of numbers.
  • perspective()Sets the distance between the viewer and the z=0 plane, giving 3D transforms depth.

Example

<div class="wrap">
<h1>CSS &lt;transform-function&gt; examples</h1>
<div class="grid">
<div class="card">
<div class="stage"><div class="tile t1">A</div></div>
<div class="label">translateX(30px)</div>
</div>
<div class="card">
<div class="stage"><div class="tile t2">A</div></div>
<div class="label">rotate(30deg)</div>
</div>
<div class="card">
<div class="stage"><div class="tile t3">A</div></div>
<div class="label">scale(1.3)</div>
</div>
<div class="card">
<div class="stage"><div class="tile t4">A</div></div>
<div class="label">skewX(-20deg)</div>
</div>
<div class="card">
<div class="stage"><div class="tile t5">A</div></div>
<div class="label">rotateY(50deg)</div>
</div>
<div class="card">
<div class="stage"><div class="tile t6">A</div></div>
<div class="label">translateX(40px) rotate(45deg)</div>
</div>
<div class="card">
<div class="stage"><div class="tile t7">A</div></div>
<div class="label">rotate(45deg) translateX(40px)</div>
</div>
</div>
<p class="note">The last two use the same functions in a different order and end up in different places.</p>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
  margin: 24px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: #f5f7fb;
  color: #102a43;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  margin: 0 0 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 12px;
  color: #486581;
  margin-top: 10px;
  word-break: break-word;
}

.note {
  font-size: 13px;
  color: #486581;
  margin-top: 14px;
}

/*  examples */
.stage {
  height: 120px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #e2e8f0;
  perspective: 500px;
}

.tile {
  width: 70px;
  height: 70px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
}

.t1 { transform: translateX(30px); }
.t2 { transform: rotate(30deg); }
.t3 { transform: scale(1.3); }
.t4 { transform: skewX(-20deg); }
.t5 { transform: rotateY(50deg); }
.t6 { transform: translateX(40px) rotate(45deg); }
.t7 { transform: rotate(45deg) translateX(40px); }
Open in editor

Browser Support

The following information will show you the current browser support for the CSS transform-function data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.

This data type is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.