This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

The CSS transform property lets you modify the coordinate space of the CSS visual formatting model. Using it, elements can be translated, rotated, scaled, and skewed.

If the property has a value different than none, a stacking context will be created. In that case the object will act as a containing block for position: fixed elements that it contains.

  • Initial value none
  • Applies to transformable elements
  • Inherited no
  • Percentages refer to the size of bounding box
  • Media visual
  • Computed value as specified, but with relative lengths converted into absolute lengths
  • Animatable yes, as a transform
  • Canonical order the unique non-ambiguous order defined by the formal grammar

Syntax

/* Keyword values */
transform: none;

/* Function values */
transform: matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
transform: translate(12px, 50%);
transform: translateX(2em);
transform: translateY(3in);
transform: scale(2, 0.5);
transform: scaleX(2);
transform: scaleY(0.5);
transform: rotate(0.5turn);
transform: skewX(30deg);
transform: skewY(1.07rad);
transform: matrix3d(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0);
transform: translate3d(12px, 50%, 3em);
transform: translateZ(2px);
transform: scale3d(2.5, 1.2, 0.3);
transform: scaleZ(0.3);
transform: rotate3d(1, 2.0, 3.0, 10deg);
transform: rotateX(10deg);
transform: rotateY(10deg);
transform: rotateZ(10deg);
transform: perspective(17px);

/* Multiple function values */
transform: translateX(10px) rotate(10deg) translateY(5px);

/* Global values */
transform: inherit;
transform: initial;
transform: unset;

Values

<transform-function>
One or more of the CSS transform functions to be applied, see below.
none
Specifies that no transform should be applied.

Formal syntax

none | <transform-list>

where
<transform-list> = <transform-function>+

Examples

See Using CSS transforms.

Live example

HTML Content

<p>Transformed element</p>

CSS Content

p {
  border: solid red;

  -webkit-transform: translate(100px) rotate(20deg);
  -webkit-transform-origin: 0 -250px;

  transform: translate(100px) rotate(20deg);
  transform-origin: 0 -250px;
}

Specifications

Specification Status Comment
CSS Transforms Level 1
The definition of 'transform' in that specification.
Working Draft Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support

(Yes) -webkit
36

3.5 (1.9.1)-moz [2]
16.0 (16.0) [4]
9.0 -ms [1]
10.0
10.5-o
12.10
15.0-webkit
23
3.1-webkit
3D Support

12.0-webkit
36

10.0-moz
16.0 (16.0)
10.0 15.0-webkit
23
4.0-webkit
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 2.1-webkit[3][4] (Yes)-webkit (Yes) (Yes)
11-webkit
11.5 (Yes)-webkit 3.2 (Yes)-webkit
3D Support 3.0-webkit (Yes)-webkit (Yes) (Yes) 22 (Yes)-webkit 3.2 (Yes)-webkit

[1] Internet Explorer 5.5 or later supports a proprietary Matrix Filter which can be used to achieve a similar effect.

[2] Gecko 14.0 removed the experimental support for skew(), but it was reintroduced in Gecko 15.0 for compatibility reasons. As it is non-standard and will likely be removed in the future, do not use it.

[3] Android 2.3 has a bug where input forms will "jump" when typing, if any container element has a <code>-webkit-transform</code>.

[4] Before Firefox 16, the translation values of matrix() and matrix3d() could be <length>, in addition to the standard <number>

See also