1. Introduction
This specification is a delta spec that extends [csstransforms1] to allow authors to transform elements in threedimensional space. New transform functions for the transform property allow threedimensional transforms, and additional properties make working with threedimensional transforms easier, and allow the author to control how nested threedimensional transformed elements interact.

The perspective property allows the author to make child elements with threedimensional transforms appear as if they live in a common threedimensional space. The perspectiveorigin property provides control over the origin at which perspective is applied, effectively changing the location of the "vanishing point".

The transformstyle property allows 3Dtransformed elements and their 3Dtransformed descendants to share a common threedimensional space, allowing the construction of hierarchies of threedimensional objects.

The backfacevisibility property comes into play when an element is flipped around via threedimensional transforms such that its reverse side is visible to the viewer. In some situations it is desirable to hide the element in this situation, which is possible using the value of hidden for this property.
Note: While some values of the transform property allow an element to be transformed in a threedimensional coordinate system, the elements themselves are not threedimensional objects. Instead, they exist on a twodimensional plane (a flat surface) and have no depth.
This specification also adds three convenience properties, scale, translate and rotate, that make it easier to describe and animate simple transforms.
2. Module Interactions
The 3D transform functions here extend the set of functions for the transform property.
Some values of perspective, transformstyle and backfacevisibility result in the creation of a containing block, and/or the creation of a stacking context.
Threedimensional transforms affect the visual layering of elements, and thus override the backtofront painting order described in Appendix E of [CSS21].
3. Terminology
 3Dtransformed element

An element whose computed value for the transform property includes one of the 3D transform functions
 3D matrix

A 4x4 matrix which does not fulfill the requirements of an <<2D matrix>>.
 identity transform function

In addition to the identity transform function in CSS Transforms, examples for identity transform functions include translate3d(0, 0, 0), translateZ(0), scaleZ(1), rotate3d(1, 1, 1, 0), rotateX(0), rotateY(0), rotateZ(0) and matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1). A special case is perspective: perspective(infinity). The value of m_{34} becomes infinitesimal small and the transform function is therefore assumed to be equal to the identity matrix.
 perspective matrix

A matrix computed from the values of the perspective and perspectiveorigin properties as described below.
 accumulated 3D transformation matrix

A matrix computed for an element relative to the root of its 3D rendering context, as described below.
 3D rendering context

A set of elements with a common ancestor which share a common threedimensional coordinate system, as described below.
3.1. Serialization of the computed value of <transformlist>
A <transformlist> for the computed value is serialized to either one <matrix()> or one <matrix3d()> function by the following algorithm:

Let transform be a 4x4 matrix initialized to the identity matrix. The elements m11, m22, m33 and m44 of transform must be set to 1 all other elements of transform must be set to 0.

Postmultiply all <transformfunction>s in <transformlist> to transform.

Chose between <matrix()> or <matrix3d()> serialization:
 If transform is a 2D matrix
 Serialize transform to a <matrix()> function.
 Otherwise
 Serialize transform to a <matrix3d()> function.
fix this text to add to the text in CSS Transforms 1.
4. Two Dimensional Subset
UAs may not always be able to render threedimensional transforms and then just support a twodimensional subset of this specification. In this case threedimensional transforms and the properties transformstyle, perspective, perspectiveorigin and backfacevisibility must not be supported. Section 3D Transform Rendering does not apply. Matrix decomposing uses the technique taken from the "unmatrix" method in "Graphics Gems II, edited by Jim Arvo", simplified for the 2D case. Section Mathematical Description of Transform Functions is still effective but can be reduced by using a 3x3 transformation matrix where a equals m_{11}, b equals m_{12}, c equals m_{21}, d equals m_{22}, e equals m_{41} and f equals m_{42} (see A 2D 3x2 matrix with six parameter).
Authors can easily provide a fallback if UAs do not provide support for threedimensional transforms. The following example has two property definitions for transform. The first one consists of two twodimensional transform functions. The second one has a twodimensional and a threedimensional transform function.
div { transform: scale(2) rotate(45deg); transform: scale(2) rotate3d(0, 0, 1, 45deg); }
With 3D support, the second definition will override the first one. Without 3D support, the second definition is invalid and a UA falls back to the first definition.
5. The Transform Rendering Model
fix this text to add to the text in CSS Transforms 1.
Threedimensional transform functions extend this coordinate space into three dimensions, adding a Z axis perpendicular to the plane of the screen, that increases towards the viewer.
The transformation matrix is computed from the transform and transformorigin properties as follows:

Start with the identity matrix.

Translate by the computed X, Y and Z of transformorigin

Multiply by each of the transform functions in transform property from left to right

Translate by the negated computed X, Y and Z values of transformorigin

5.1. 3D Transform Rendering
Normally, elements render as flat planes, and are rendered into the same plane as their containing block. Often this is the plane shared by the rest of the page. Twodimensional transform functions can alter the appearance of an element, but that element is still rendered into the same plane as its containing block.
Threedimensional transforms can result in transformation matrices with a nonzero Z component (where the Z axis projects out of the plane of the screen). This can result in an element rendering on a different plane than that of its containing block. This may affect the fronttoback rendering order of that element relative to other elements, as well as causing it to intersect with other elements.
This example shows the effect of threedimensional transform applied to an element.
<style> div { height: 150px; width: 150px; } .container { border: 1px solid black; } .transformed { transform: rotateY(50deg); } </style> <div class="container"> <div class="transformed"></div> </div>
The transform is a 50° rotation about the vertical, Y axis. Note how this makes the blue box appear narrower, but not threedimensional.
5.1.1. Perspective
The perspective and perspectiveorigin properties can be used to add a feeling of depth to a scene by making elements higher on the Z axis (closer to the viewer) appear larger, and those further away to appear smaller. The scaling is proportional to d/(d − Z) where d, the value of perspective, is the distance from the drawing plane to the the assumed position of the viewer’s eye.
Normally the assumed position of the viewer’s eye is centered on a drawing. This position can be moved if desired – for example, if a web page contains multiple drawings that should share a common perspective – by setting perspectiveorigin.
The perspective matrix is computed as follows:
 Start with the identity matrix.
 Translate by the computed X and Y values of perspectiveorigin
 Multiply by the matrix that would be obtained from the perspective() transform function, where the length is provided by the value of the perspective property
 Translate by the negated computed X and Y values of perspectiveorigin
This example shows how perspective can be used to cause threedimensional transforms to appear more realistic.
<style> div { height: 150px; width: 150px; } .container { perspective: 500px; border: 1px solid black; } .transformed { transform: rotateY(50deg); } </style> <div class="container"> <div class="transformed"></div> </div>
The inner element has the same transform as in the previous example, but its rendering is now influenced by the perspective property on its parent element. Perspective causes vertices that have positive Z coordinates (closer to the viewer) to be scaled up in X and Y, and those further away (negative Z coordinates) to be scaled down, giving an appearance of depth.
5.1.2. 3D Rendering Contexts
This section specifies the rendering model for content that uses 3Dtransforms and the transformstyle property. In order to describe this model, we introduce the concept of a "3D rendering context".
A 3D rendering context is a set of elements rooted in a common ancestor that, for the purposes of 3Dtransform rendering, are considered to share a common threedimensional coordinate system. The fronttoback rendering of elements in the a 3D rendering context depends on their zposition in that threedimensional space, and, if the 3D transforms on those elements cause them to intersect, then they are rendered with intersection.
A 3D rendering context is established by an element which has a used value for transformstyle of "flat". Descendant elements with a used value for transformstyle of "auto" or "preserve3d" share their enclosing 3D rendering context. A descendant with a used value for transformstyle of "flat" participates in its containing 3D rendering context, but establishes a new 3D rendering context for its descendants. For the purposes of rendering in its containing 3D rendering context, it behaves like a flat plane.
Note: This is conceptually similar to CSS stacking contexts. A positioned element with explicit zindex establishes a stacking context, while participating in the stacking context of an ancestor. Similarly, an element can establish a 3D rendering context for its descendants, while participating in the 3D rendering context of an ancestor. Just as elements within a stacking context render in zindex order, elements in a 3Drendering context render in zdepth order and can intersect.
Some CSS properties have values that are considered to force "grouping": they require that their element and its descendants are rendered as a group before being composited with other elements; these include opacity, filters and properties that affect clipping. The relevant property values are listed under grouping property values. These grouping property values force the used value for transformstyle to be "flat", and such elements are referred to as flattening elements. Consequently, they always establish a new 3D rendering context. The root element always has a used value of "flat" for transformstyle.
The rendering of elements in a 3D rendering context is as follows (numbers refer to items in CSS 2.1, Appendix E, Section E.2 Painting Order):
 The background, borders and other box decorations of the establishing element are rendered (steps 1 and 2)
 The content and descendant elements without 3D transforms, ordered according to steps 3—7, are rendered into a plane at z=0 relative to to the establishing element.
 3Dtransformed elements are each rendered into their own plane, transformed by the accumulated 3D transformation matrix.
 Intersection is performed between the set of planes generated by steps B and C, according to Newell’s algorithm.
 The resulting set of planes is rendered on top of the backgrounds and box decorations rendered in this step A. Coplanar 3D transformed elements are rendered in painting order.
is it OK to not pop 2Dtransformed elements into their own planes?
requiring intersection with nontransformed content and descendants requires UAs to allocate additional textures (possibly doubling memory use). Would be more efficient to simply render content and untransformed descendants along with background and borders.
Note that elements with transforms which have a negative zcomponent will render behind the content and untransformed descendants of the establishing element, and that 3D transformed elements may interpenetrate with content and untransformed elements.
Note: Because the 3Dtransformed elements in a 3D rendering context can all depthsort and intersect with each other, they are effectively rendered as if they were siblings. The effect of transformstyle: preserve3d can then be thought of as causing all the 3D transformed elements in a 3D rendering context to be hoisted up into the establishing element, but still rendered with their accumulated 3D transformation matrix.
<style> .container { backgroundcolor: rgba(0, 0, 0, 0.3); perspective: 500px; } .container > div { position: absolute; left: 0; } .container > :firstchild { transform: rotateY(45deg); backgroundcolor: orange; top: 10px; height: 135px; } .container > :lastchild { transform: translateZ(40px); backgroundcolor: rgba(0, 0, 255, 0.6); top: 50px; height: 100px; } </style> <div class="container"> <div></div> <div></div> </div>
This example shows show elements in a 3D rendering context can intersect. The container element establishes a 3D rendering context for itself and its two children. The children intersect with each other, and the orange element also intersects with the container.
The perspective property can be used to ensure that 3D transformed elements in the resulting 3D rendering context appear to live in a common threedimensional space with depth, by suppling a common perspective matrix to descendant transformed members of its 3D rendering context, which is taken into account in the accumulated 3D matrix computation.
By default, elements with value for perspective other than none are flattening, and thus establish a 3D rendering context. However, setting transformstyle to preserve3d allows the perspective element to extend its containing 3D rendering context (provided no other grouping property values are in effect).
<style> div { height: 150px; width: 150px; } .container { perspective: 500px; border: 1px solid black; } .transformed { transform: rotateY(50deg); backgroundcolor: blue; } .child { transformorigin: top left; transform: rotateX(40deg); backgroundcolor: lime; } </style> <div class="container"> <div class="transformed"> <div class="child"></div> </div> </div>
This example shows how nested 3D transforms are rendered. The blue div is transformed as in the previous example, with its rendering influenced by the perspective on its parent element. The lime element also has a 3D transform, which is a rotation about the X axis (anchored at the top, by virtue of the transformorigin). However, the lime element is being rendered into the plane of its parent because it is not a member of the same 3D rendering context; the parent is "flattening". Thus the lime element only appears shorter; it does not "pop out" of the blue element.
5.1.3. Transformed element hierarchies
By default, transformed elements are flattening, and thus establish a 3D rendering context. However, since it is useful to construct hierarchies of transformed objects that share a common 3dimensional space, this flattening behavior may be overridden by specifying a value of preserve3d for the transformstyle property, provided no other grouping property values are in effect. This allows descendants of the transformed element to share the same 3D rendering context. Non3Dtransformed descendants of such elements are rendered into the plane of the element in step C above, but 3Dtransformed elements in the same 3D rendering context will "pop out" into their own planes.
<style> div { height: 150px; width: 150px; } .container { perspective: 500px; border: 1px solid black; } .transformed { transformstyle: preserve3d; transform: rotateY(50deg); backgroundcolor: blue; } .child { transformorigin: top left; transform: rotateX(40deg); backgroundcolor: lime; } </style>
This example is identical to the previous example, with the addition of transformstyle: preserve3d on the blue element. The blue element now extends the 3D rendering context of its container. Now both blue and lime elements share a common threedimensional space, so the lime element renders as tilting out from its parent, influenced by the perspective on the container.
5.1.4. Accumulated 3D Transformation Matrix Computation
The final value of the transform used to render an element in a 3D rendering context is computed by accumulating an accumulated 3D transformation matrix as follows:

Let transform be the identity matrix.

Let current element be the transformed element.

Let ancestor block be the element that establishes the transformed element’s containing block.

While current element is not the element that establishes the transformed element’s 3D rendering context:

If current element has a value for transform which is not none, premultiply current element’s transformation matrix with the transform.

Compute a translation matrix which represents the offset of current element from its ancestor block, and premultiply that matrix into the transform.

If ancestor block has a value for perspective which is not none, premultiply the ancestor block’s perspective matrix into the transform.

Let ancestor block be the element that establishes the current element’s containing block.

Let current element be the ancestor block.

Note: as described here, the accumulated 3D transformation matrix takes into account offsets generated by the visual formatting model on the transformed element, and elements in the ancestor chain between the transformed element and the element that establishes the its 3D rendering context.
5.1.5. Backface Visibility
Using threedimensional transforms, it’s possible to transform an element such that its reverse side is visible. 3Dtransformed elements show the same content on both sides, so the reverse side looks like a mirrorimage of the front side (as if the element were projected onto a sheet of glass). Normally, elements whose reverse side is towards the viewer remain visible. However, the backfacevisibility property allows the author to make an element invisible when its reverse side is towards the viewer. This behavior is "live"; if an element with backfacevisibility: hidden were animating, such that its front and reverse sides were alternately visible, then it would only be visible when the front side were towards the viewer.
Visibility of the reverse side of an element is considered using the accumulated 3D transformation matrix, and is thus relative to the enclosing flattening element.
Note: This property is useful when you place two elements backtoback, as you would to create a playing card. Without this property, the front and back elements could switch places at times during an animation to flip the card. Another example is creating a box out of 6 elements, but where you want to see only the inside faces of the box.
This example shows how to make a "card" element that flips over when clicked. Note the "transformstyle: preserve3d" on #card which is necessary to avoid flattening when flipped.
<style> .body { perspective: 500px; } #card { position: relative; height: 300px; width: 200px; transition: transform 1s; transformstyle: preserve3d; } #card.flipped { transform: rotateY(180deg); } .face { position: absolute; top: 0; left: 0; width: 100%; height: 100%; backgroundcolor: silver; borderradius: 40px; backfacevisibility: hidden; } .back { transform: rotateY(180deg); } </style> <div id="card" onclick="this.classList.toggle('flipped')"> <div class="front face">Front</div> <div class="back face">Back</div> </div>
what is the impact of backfacevisibility on nontransformed or 2Dtransformed elements? Do they get popped into their own planes and intersect?
5.2. Processing of PerspectiveTransformed Boxes
This is a first pass at an attempt to precisely specify how exactly to transform elements using the provided matrices. It might not be ideal, and implementer feedback is encouraged. See bug 15605.
The accumulated 3D transformation matrix is affected both by the perspective property, and by any perspective() transform function present in the value of the transform property.
This accumulated 3D transformation matrix is a 4×4 matrix, while the objects to be transformed are twodimensional boxes. To transform each corner (a, b) of a box, the matrix must first be applied to (a, b, 0, 1), which will result in a fourdimensional point (x, y, z, w). This is transformed back to a threedimensional point (x′, y′, z′) as follows:
If w > 0, (x′, y′, z′) = (x/w, y/w, z/w).
If w = 0, (x′, y′, z′) = (x ⋅ n, y ⋅ n, z ⋅ n). n is an implementationdependent value that should be chosen so that x′ or y′ is much larger than the viewport size, if possible. For example, (5px, 22px, 0px, 0) might become (5000px, 22000px, 0px), with n = 1000, but this value of n would be too small for (0.1px, 0.05px, 0px, 0). This specification does not define the value of n exactly. Conceptually, (x′, y′, z′) is infinitely far in the direction (x, y, z).
If w < 0 for all four corners of the transformed box, the box is not rendered.
If w < 0 for one to three corners of the transformed box, the box must be replaced by a polygon that has any parts with w < 0 cut out. This will in general be a polygon with three to five vertices, of which exactly two will have w = 0 and the rest w > 0. These vertices are then transformed to threedimensional points using the rules just stated. Conceptually, a point with w < 0 is "behind" the viewer, so should not be visible.
.transformed { height: 100px; width: 100px; background: lime; transform: perspective(50px) translateZ(100px); }
All of the box’s corners have zcoordinates greater than the perspective. This means that the box is behind the viewer and will not display. Mathematically, the point (x, y) first becomes (x, y, 0, 1), then is translated to (x, y, 100, 1), and then applying the perspective results in (x, y, 100, −1). The wcoordinate is negative, so it does not display. An implementation that doesn’t handle the w < 0 case separately might incorrectly display this point as (−x, −y, −100), dividing by −1 and mirroring the box.
.transformed { height: 100px; width: 100px; background: radialgradient(yellow, blue); transform: perspective(50px) translateZ(50px); }
Here, the box is translated upward so that it sits at the same place the viewer is looking from. This is like bringing the box closer and closer to one’s eye until it fills the entire field of vision. Since the default transformorigin is at the center of the box, which is yellow, the screen will be filled with yellow.
Mathematically, the point (x, y) first becomes (x, y, 0, 1), then is translated to (x, y, 50, 1), then becomes (x, y, 50, 0) after applying perspective. Relative to the transformorigin at the center, the upperleft corner was (−50, −50), so it becomes (−50, −50, 50, 0). This is transformed to something very far to the upper left, such as (−5000, −5000, 5000). Likewise the other corners are sent very far away. The radial gradient is stretched over the whole box, now enormous, so the part that’s visible without scrolling should be the color of the middle pixel: yellow. However, since the box is not actually infinite, the user can still scroll to the edges to see the blue parts.
.transformed { height: 50px; width: 50px; background: lime; border: 25px solid blue; transformorigin: left; transform: perspective(50px) rotateY(45deg); }
The box will be rotated toward the viewer, with the left edge staying fixed while the right edge swings closer. The right edge will be at about z = 70.7px, which is closer than the perspective of 50px. Therefore, the rightmost edge will vanish ("behind" the viewer), and the visible part will stretch out infinitely far to the right.
Mathematically, the top right vertex of the box was originally (100, −50), relative to the transformorigin. It is first expanded to (100, −50, 0, 1). After applying the transform specified, this will get mapped to about (70.71, −50, 70.71, −0.4142). This has w = −0.4142 < 0, so we need to slice away the part of the box with w < 0. This results in the new topright vertex being (50, −50, 50, 0). This is then mapped to some faraway point in the same direction, such as (5000, −5000, 5000), which is up and to the right from the transformorigin. Something similar is done to the lower right corner, which gets mapped far down and to the right. The resulting box stretches far past the edge of the screen.
Again, the rendered box is still finite, so the user can scroll to see the whole thing if he or she chooses. However, the right part has been chopped off. No matter how far the user scrolls, the rightmost 30px or so of the original box will not be visible. The blue border was only 25px wide, so it will be visible on the left, top, and bottom, but not the right.
The same basic procedure would apply if one or three vertices had w < 0. However, in that case the result of truncating the w < 0 part would be a triangle or pentagon instead of a quadrilateral.
6. Individual Transform Properties: the translate, scale, and rotate properties
Fluff here.
Name:  translate 

Value:  none  <lengthpercentage> [ <lengthpercentage> <length>? ]? 
Initial:  none 
Applies to:  transformable elements 
Inherited:  no 
Percentages:  relative to the width of the containing block (for the first value) or the height (for the second value) 
Media:  visual 
Computed value:  as specified, with lengths made absolute 
Canonical order:  per grammar 
Animatable:  as <length> or <percentage> list 
Name:  rotate 

Value:  none  <number>{3}? <angle> 
Initial:  none 
Applies to:  transformable elements 
Inherited:  no 
Percentages:  n/a 
Media:  visual 
Computed value:  as specified 
Canonical order:  per grammar 
Animatable:  as SLERP 
Name:  scale 

Value:  none  <number>{1,3} 
Initial:  none 
Applies to:  transformable elements 
Inherited:  no 
Percentages:  n/a 
Media:  visual 
Computed value:  as specified 
Canonical order:  per grammar 
Animatable:  as <number> list 
The translate, rotate, and scale properties allow authors to specify simple transforms independently, in a way that maps to typical user interface usage, rather than having to remember the order in transform that keeps the actions of transform(), rotate() and scale() independent and acting in screen coordinates.
The translate property accepts 13 values, each specifying a translation against one axis, in the order X, Y, then Z. Unspecified translations default to 0px.
The rotate property accepts an angle to rotate an element, and optionally an axis to rotate it around, specified as the X, Y, and Z lengths of an originanchored vector. If the axis is unspecified, it defaults to 0 0 1, causing a "2d rotation" in the plane of the screen.
The scale property accepts 13 values, each specifying a scale along one axis, in order X, Y, then Z. Unspecified scales default to 1.
All three properties accept (and default to) the value none, which produces no transform at all. In particular, this value does not trigger the creation of a stacking context or containing block, while all other values (including identity transforms like translate: 0px) create a stacking context and containing block, per usual for transforms.
When translate, rotate or scale are animating or transitioning, and the from value or to value (but not both) is none, the value none is replaced by the equivalent identity value (0px for translate, 0deg for rotate, 1 for scale).
7. Current Transformation Matrix
The transformation matrix computation is amended to the following:
The transformation matrix is computed from the transform, transformorigin, translate, rotate, scale, and motion properties as follows:

Start with the identity matrix.

Translate by the computed X, Y, and Z values of transformorigin.

Translate by the computed X, Y, and Z values of translate.

Rotate by the computed <angle> about the specified axis of rotate.

Scale by the computed X, Y, and Z values of scale.

Translate and rotate by the transform specified by motion.

Multiply by each of the transform functions in transform from left to right.

Translate by the negated computed X, Y and Z values of transformorigin.
8. The transformstyle Property
Name:  transformstyle 

Value:  auto  flat  preserve3d 
Initial:  auto 
Applies to:  transformable elements 
Inherited:  no 
Percentages:  N/A 
Media:  visual 
Computed value:  Same as specified value. 
Canonical order:  per grammar 
Animatable:  no 
A value of "flat" for transformstyle establishes a stacking context, and establishes a 3D rendering context. Elements with a used value of "auto" are ignored for the purposes of 3D rendering context computation, and those with a used value of "preserve3d" extend the 3D rendering context to which they belong, even if values for the transform or perspective properties would otherwise cause flattening. A value of "preserve3d" establishes a stacking context, and a containing block.
8.1. Grouping property values
The following CSS property values require the user agent to create a flattened representation of the descendant elements before they can be applied, and therefore force the used value of transformstyle to flat:

opacity: any value less than 1.

filter: any value other than none.

clip: any value other than auto.

clippath: any value other than none.

isolation: used value of isolate.

maskimage: any value other than none.

maskbordersource: any value other than none.

mixblendmode: any value other than normal.
The following CSS property values cause an auto value of transformstyle to become flat:

transform: any value other than none.

perspective: any value other than none.
In both cases the computed value of transformstyle is not affected.
Having overflow imply transformstyle: flat causes every element with nonvisible overflow to become a stacking context, which is unwanted. See Bug 28252.
9. The perspective Property
Name:  perspective 

Value:  none  <length> 
Initial:  none 
Applies to:  transformable elements 
Inherited:  no 
Percentages:  N/A 
Media:  visual 
Computed value:  Absolute length or "none". 
Canonical order:  per grammar 
Animatable:  as length 
Where <length> values must be positive.
 <length>

Distance to the center of projection.
Verify that projection is the distance to the center of projection.
 none

No perspective transform is applied. The effect is mathematically similar to an infinite <length> value. All objects appear to be flat on the canvas.
The use of this property with any value other than none establishes a stacking context. It also establishes a containing block (somewhat similar to position: relative), just like the transform property does.
The values of the perspective and perspectiveorigin properties are used to compute the perspective matrix, as described above.
10. The perspectiveorigin Property
The perspectiveorigin property establishes the origin for the perspective property. It effectively sets the X and Y position at which the viewer appears to be looking at the children of the element.
Name:  perspectiveorigin 

Value:  <position> 
Initial:  50% 50% 
Applies to:  transformable elements 
Inherited:  no 
Percentages:  refer to the size of the reference box 
Media:  visual 
Computed value:  For <length> the absolute value, otherwise a percentage. 
Canonical order:  per grammar 
Animatable:  as simple list of length, percentage, or calc 
The values of the perspective and perspectiveorigin properties are used to compute the perspective matrix, as described above.
The values for perspectiveorigin represent an offset of the perspective origin from the top left corner of the reference box.
 <percentage>

A percentage for the horizontal perspective offset is relative to the width of the reference box. A percentage for the vertical offset is relative to height of the reference box. The value for the horizontal and vertical offset represent an offset from the top left corner of the reference box.
 <length>

A length value gives a fixed length as the offset. The value for the horizontal and vertical offset represent an offset from the top left corner of the reference box.
 top

Computes to 0% for the vertical position if one or two values are given, otherwise specifies the top edge as the origin for the next offset.
 right

Computes to 100% for the horizontal position if one or two values are given, otherwise specifies the right edge as the origin for the next offset.
 bottom

Computes to 100% for the vertical position if one or two values are given, otherwise specifies the bottom edge as the origin for the next offset.
 left

Computes to 0% for the horizontal position if one or two values are given, otherwise specifies the left edge as the origin for the next offset.
 center

Computes to 50% (left 50%) for the horizontal position if the horizontal position is not otherwise specified, or 50% (top 50%) for the vertical position if it is.
The perspectiveorigin property is a resolved value special case property like height. [CSSOM]
11. The backfacevisibility Property
Name:  backfacevisibility 

Value:  visible  hidden 
Initial:  visible 
Applies to:  transformable elements 
Inherited:  no 
Percentages:  N/A 
Media:  visual 
Computed value:  Same as specified value. 
Canonical order:  per grammar 
Animatable:  no 
The visibility of an element with backfacevisibility: hidden is determined as follows:

Compute the element’s accumulated 3D transformation matrix.

If the component of the matrix in row 3, column 3 is negative, then the element should be hidden. Otherwise it is visible.
Backfacevisibility cannot be tested by only looking at m33. See Bug 23014.
Note: The reasoning for this definition is as follows. Assume elements are rectangles in the x–y plane with infinitesimal thickness. The front of the untransformed element has coordinates like (x, y, ε), and the back is (x, y, −ε), for some very small ε. We want to know if after the transformation, the front of the element is closer to the viewer than the back (higher zvalue) or further away. The zcoordinate of the front will be m_{13}x + m_{23}y + m_{33}ε + m_{43}, before accounting for perspective, and the back will be m_{13}x + m_{23}y − m_{33}ε + m_{43}. The first quantity is greater than the second if and only if m_{33} > 0. (If it equals zero, the front and back are equally close to the viewer. This probably means something like a 90degree rotation, which makes the element invisible anyway, so we don’t really care whether it vanishes.)
12. SVG and 3D transform functions
This specification explicitly requires threedimensional transform functions to apply to the container elements: a
, g
, svg
, all graphics elements, all graphics referencing elements and the SVG foreignObject
element.
Threedimensional transform functions and the properties perspective, perspectiveorigin, transformstyle and backfacevisibility can not be used for the elements: clipPath
, linearGradient
, radialGradient
and pattern
. If a transform list includes a threedimensional transform function, the complete transform list must be ignored. The values of every previously named property must be ignored. Transformable elements that are contained by one of these elements can have threedimensional transform functions. The clipPath
, mask
, pattern
elements require the user agent to create a flattened representation of the descendant elements before they can be applied, and therefore override the behavior of transformstyle: preserve3d.
If the vectoreffect property is set to nonscalingstroke and an object is within a 3D rendering context the property has no affect on stroking the object.
13. The Transform Functions
The value of the transform property is a list of <transformfunction>. The set of allowed transform functions is given below. Wherever <angle> is used in this specification, a <number> that is equal to zero is also allowed, which is treated the same as an angle of zero degrees. A percentage for horizontal translations is relative to the width of the reference box. A percentage for vertical translations is relative to the height of the reference box.
13.1. 3D Transform Functions
In the following 3d transform functions, a <zero> behaves the same as 0deg. ("Unitless 0" angles are preserved for legacy compat reasons.)
 matrix3d() = matrix3d( <number> [, <number> ]{15,15} )

specifies a 3D transformation as a 4x4 homogeneous matrix of 16 values in columnmajor order.
 translate3d() = translate3d( <lengthpercentage> , <lengthpercentage> , <length> )

specifies a 3D translation by the vector [tx,ty,tz], with tx, ty and tz being the first, second and third translationvalue parameters respectively.
 translateZ() = translateZ( <length> )

specifies a 3D translation by the vector [0,0,tz] with the given amount in the Z direction.
 scale3d() = scale3d( <number> , <number>, <number> )

specifies a 3D scale operation by the [sx,sy,sz] scaling vector described by the 3 parameters.
 scaleZ() = scaleZ( <number> )

specifies a 3D scale operation using the [1,1,sz] scaling vector, where sz is given as the parameter.
 rotate3d() = rotate3d( <number> , <number> , <number> , [ <angle>  <zero> ] )

specifies a 3D rotation by the angle specified in last parameter about the [x,y,z] direction vector described by the first three parameters. A direction vector that cannot be normalized, such as [0,0,0], will cause the rotation to not be applied.
Note: the rotation is clockwise as one looks from the end of the vector toward the origin.
 rotateX() = rotateX( [ <angle>  <zero> ] )

same as rotate3d(1, 0, 0, <angle>).
 rotateY() = rotateY( [ <angle>  <zero> ] )

same as rotate3d(0, 1, 0, <angle>).
 rotateZ() = rotateZ( [ <angle>  <zero> ] )

same as rotate3d(0, 0, 1, <angle>), which is also the same as rotate(<angle>).
 perspective() = perspective( <length> )

specifies a perspective projection matrix. This matrix scales points in X and Y based on their Z value, scaling points with positive Z values away from the origin, and those with negative Z values towards the origin. Points on the z=0 plane are unchanged. The parameter represents the distance of the z=0 plane from the viewer. Lower values give a more flattened pyramid and therefore a more pronounced perspective effect. For example, a value of 1000px gives a moderate amount of foreshortening and a value of 200px gives an extreme amount. The value for depth must be greater than zero, otherwise the function is invalid.
13.2. Interpolation of 3D matrices
13.2.1. Decomposing a 3D matrix
The pseudo code below is based upon the "unmatrix" method in "Graphics Gems II, edited by Jim Arvo", but modified to use Quaternions instead of Euler angles to avoid the problem of Gimbal Locks.
The following pseudocode works on a 4x4 homogeneous matrix:
Input: matrix ; a 4x4 matrix Output: translation ; a 3 component vector scale ; a 3 component vector skew ; skew factors XY,XZ,YZ represented as a 3 component vector perspective ; a 4 component vector quaternion ; a 4 component vector Returns false if the matrix cannot be decomposed, true if it can // Normalize the matrix. if (matrix[3][3] == 0) return false for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) matrix[i][j] /= matrix[3][3] // perspectiveMatrix is used to solve for perspective, but it also provides // an easy way to test for singularity of the upper 3x3 component. perspectiveMatrix = matrix for (i = 0; i < 3; i++) perspectiveMatrix[i][3] = 0 perspectiveMatrix[3][3] = 1 if (determinant(perspectiveMatrix) == 0) return false // First, isolate perspective. if (matrix[0][3] != 0  matrix[1][3] != 0  matrix[2][3] != 0) // rightHandSide is the right hand side of the equation. rightHandSide[0] = matrix[0][3] rightHandSide[1] = matrix[1][3] rightHandSide[2] = matrix[2][3] rightHandSide[3] = matrix[3][3] // Solve the equation by inverting perspectiveMatrix and multiplying // rightHandSide by the inverse. inversePerspectiveMatrix = inverse(perspectiveMatrix) transposedInversePerspectiveMatrix = transposeMatrix4(inversePerspectiveMatrix) perspective = multVecMatrix(rightHandSide, transposedInversePerspectiveMatrix) else // No perspective. perspective[0] = perspective[1] = perspective[2] = 0 perspective[3] = 1 // Next take care of translation for (i = 0; i < 3; i++) translate[i] = matrix[3][i] // Now get scale and shear. 'row' is a 3 element array of 3 component vectors for (i = 0; i < 3; i++) row[i][0] = matrix[i][0] row[i][1] = matrix[i][1] row[i][2] = matrix[i][2] // Compute X scale factor and normalize first row. scale[0] = length(row[0]) row[0] = normalize(row[0]) // Compute XY shear factor and make 2nd row orthogonal to 1st. skew[0] = dot(row[0], row[1]) row[1] = combine(row[1], row[0], 1.0, skew[0]) // Now, compute Y scale and normalize 2nd row. scale[1] = length(row[1]) row[1] = normalize(row[1]) skew[0] /= scale[1]; // Compute XZ and YZ shears, orthogonalize 3rd row skew[1] = dot(row[0], row[2]) row[2] = combine(row[2], row[0], 1.0, skew[1]) skew[2] = dot(row[1], row[2]) row[2] = combine(row[2], row[1], 1.0, skew[2]) // Next, get Z scale and normalize 3rd row. scale[2] = length(row[2]) row[2] = normalize(row[2]) skew[1] /= scale[2] skew[2] /= scale[2] // At this point, the matrix (in rows) is orthonormal. // Check for a coordinate system flip. If the determinant // is 1, then negate the matrix and the scaling factors. pdum3 = cross(row[1], row[2]) if (dot(row[0], pdum3) < 0) for (i = 0; i < 3; i++) scale[i] *= 1; row[i][0] *= 1 row[i][1] *= 1 row[i][2] *= 1 // Now, get the rotations out quaternion[0] = 0.5 * sqrt(max(1 + row[0][0]  row[1][1]  row[2][2], 0)) quaternion[1] = 0.5 * sqrt(max(1  row[0][0] + row[1][1]  row[2][2], 0)) quaternion[2] = 0.5 * sqrt(max(1  row[0][0]  row[1][1] + row[2][2], 0)) quaternion[3] = 0.5 * sqrt(max(1 + row[0][0] + row[1][1] + row[2][2], 0)) if (row[2][1] > row[1][2]) quaternion[0] = quaternion[0] if (row[0][2] > row[2][0]) quaternion[1] = quaternion[1] if (row[1][0] > row[0][1]) quaternion[2] = quaternion[2] return true
13.2.2. Interpolation of decomposed 3D matrix values
Each component of the decomposed values translation, scale, skew and perspective of the source matrix get linearly interpolated with each corresponding component of the destination matrix.
Note: For instance, translate[0]
of the source matrix and translate[0]
of the destination matrix are interpolated numerically, and the result is used to set the translation of the animating element.
Quaternions of the decomposed source matrix are interpolated with quaternions of the decomposed destination matrix using the spherical linear interpolation (Slerp) as described by the pseudo code below:
Input: quaternionA ; a 4 component vector quaternionB ; a 4 component vector t ; interpolation parameter with 0 <= t <= 1 Output: quaternionDst ; a 4 component vector product = dot(quaternionA, quaternionB) // Clamp product to 1.0 <= product <= 1.0 product = max(product, 1.0) product = min(product, 1.0) if (product == 1.0) quaternionDst = quaternionA return theta = acos(dot) w = sin(t * theta) * 1 / sqrt(1  product * product) for (i = 0; i < 4; i++) quaternionA[i] *= cos(t * theta)  product * w quaternionB[i] *= w quaternionDst[i] = quaternionA[i] + quaternionB[i] return
13.2.3. Recomposing to a 3D matrix
After interpolation, the resulting values are used to transform the elements user space. One way to use these values is to recompose them into a 4x4 matrix. This can be done following the pseudo code below:
Input: translation ; a 3 component vector scale ; a 3 component vector skew ; skew factors XY,XZ,YZ represented as a 3 component vector perspective ; a 4 component vector quaternion ; a 4 component vector Output: matrix ; a 4x4 matrix Supporting functions (matrix is a 4x4 matrix): matrix multiply(matrix a, matrix b) returns the 4x4 matrix product of a * b // apply perspective for (i = 0; i < 4; i++) matrix[i][3] = perspective[i] // apply translation for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) matrix[3][i] += translation[j] * matrix[j][i] // apply rotation x = quaternion[0] y = quaternion[1] z = quaternion[2] w = quaternion[3] // Construct a composite rotation matrix from the quaternion values // rotationMatrix is a identity 4x4 matrix initially rotationMatrix[0][0] = 1  2 * (y * y + z * z) rotationMatrix[0][1] = 2 * (x * y  z * w) rotationMatrix[0][2] = 2 * (x * z + y * w) rotationMatrix[1][0] = 2 * (x * y + z * w) rotationMatrix[1][1] = 1  2 * (x * x + z * z) rotationMatrix[1][2] = 2 * (y * z  x * w) rotationMatrix[2][0] = 2 * (x * z  y * w) rotationMatrix[2][1] = 2 * (y * z + x * w) rotationMatrix[2][2] = 1  2 * (x * x + y * y) matrix = multiply(matrix, rotationMatrix) // apply skew // temp is a identity 4x4 matrix initially if (skew[2]) temp[2][1] = skew[2] matrix = multiply(matrix, temp) if (skew[1]) temp[2][1] = 0 temp[2][0] = skew[1] matrix = multiply(matrix, temp) if (skew[0]) temp[2][0] = 0 temp[1][0] = skew[0] matrix = multiply(matrix, temp) // apply scale for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) matrix[i][j] *= scale[i] return
14. Interpolation of Matrices
When interpolating between two matrices, each matrix is decomposed into the corresponding translation, rotation, scale, skew and (for a 3D matrix) perspective values. Each corresponding component of the decomposed matrices gets interpolated numerically and recomposed back to a matrix in a final step.
14.1. Neutral element for addition
Some animations require a neutral element for addition. For transform functions this is a scalar or a list of scalars of 0. Examples of neutral elements for transform functions are translate(0), translate3d(0, 0, 0), translateX(0), translateY(0), translateZ(0), scale(0), scaleX(0), scaleY(0), scaleZ(0), rotate(0), rotate3d(vx, vy, vz, 0) (where v is a context dependent vector), rotateX(0), rotateY(0), rotateZ(0), skew(0, 0), skewX(0), skewY(0), matrix(0, 0, 0, 0, 0, 0), matrix3d(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) and perspective(0).
Note: Animations to or from the neutral element of additions <matrix()>, matrix3d() and perspective() fall back to discrete animations (See §14 Interpolation of Matrices).
15. Interpolation of primitives and derived transform functions
Two transform functions with the same name and the same number of arguments are interpolated numerically without a former conversion. The calculated value will be of the same transform function type with the same number of arguments. Special rules apply to <matrix()>, <matrix3d()> and <perspective()>.
The transform functions <matrix()>, matrix3d() and perspective() get converted into 4x4 matrices first and interpolated as defined in section Interpolation of Matrices afterwards.
For interpolations with the primitive rotate3d(), the direction vectors of the transform functions get normalized first. If the normalized vectors are equal, the rotation angle gets interpolated numerically. Otherwise the transform functions get converted into 4x4 matrices first and interpolated as defined in section Interpolation of Matrices afterwards.
16. Mathematical Description of Transform Functions
Mathematically, all transform functions can be represented as 4x4 transformation matrices of the following form:
One translation unit on a matrix is equivalent to 1 pixel in the local coordinate system of the element.
 A 3D translation with the parameters tx, ty and tz is equivalent to the matrix:
 A 3D scaling with the parameters sx, sy and sz is equivalent to the matrix:

A 3D rotation with the vector [x,y,z] and the parameter alpha is equivalent to the matrix:
where:
 A perspective projection matrix with the parameter d is equivalent to the matrix:
17. The SVG transform Attribute
This specification will also introduce the new presentation attributes transformorigin, perspective, perspectiveorigin, transformstyle and backfacevisibility.
Values on new introduced presentation attributes get parsed following the syntax rules on SVG Data Types [SVG11].
18. SVG Animation
18.1. The animate
and set
element
The introduce presentation attributes perspective, perspectiveorigin, transformstyle and backfacevisibility are animatable. transformstyle and backfacevisibility are nonadditive.
19. More Issues
Per https://lists.w3.org/Archives/Public/wwwstyle/2015Mar/0371.html, the WG resolved to add a formula for decomposing a transform into a unified "scale" (the spec already defines how to decompose it into scaleX/Y/Z), for use by things like SVG’s nonscaling stroke spec. Formula is defined here.
20. Security and Privacy Considerations
This specification introduces no new security or privacy considerations.