The matrix() CSS function defines a homogeneous 2D transformation matrix. Its result is a <transform-function> data type.

Note: matrix(a, b, c, d, tx, ty) is a shorthand for matrix3d(a, b, 0, 0, c, d, 0, 0, 0, 0, 1, 0, tx, ty, 0, 1).


The matrix() function is specified with six values. The constant values are implied and not passed as parameters; the other parameters are described in the column-major order.

Note: Until Firefox 16, Gecko accepted a <length> value for tx and ty.
matrix(a, b, c, d, tx, ty)


a b c d
Are <number>s describing the linear transformation.
tx ty
Are <number>s describing the translation to apply.
Cartesian coordinates on ℝ2 Homogeneous coordinates on ℝℙ2 Cartesian coordinates on ℝ3 Homogeneous coordinates on ℝℙ3
ac bd actxbdty001 actxbdty001 ac0txbd0ty00100001
[a b c d tx ty]



<div class="changed">Changed</div>


div {
  width: 80px;
  height: 80px;
  background-color: skyblue;

.changed {
  transform: matrix(1, 2, -1, 1, 80, 80);
  background-color: pink;


Browser compatibility

Please see the <transform-function> data type for compatibility info.

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.