--- title: transform-origin slug: Web/SVG/Attribute/transform-origin page-type: svg-attribute browser-compat: svg.global_attributes.transform-origin --- {{SVGRef()}} The **`transform-origin`** SVG attribute sets the origin for an item's transformations. You can use this attribute with any SVG element. > [!NOTE] > As a presentation attribute in SVG, `transform-origin` corresponds in syntax and behavior to the `transform-origin` property in CSS, and can be used as CSS property to style SVG. See the [CSS transform-origin](/en-US/docs/Web/CSS/transform-origin) property for more information. ## Usage notes
Values See {{cssxref("transform-origin", "", "#formal_syntax")}}
Default value 0, 0
Animatable Yes
> [!NOTE] > The default value of `transform-origin` is `0 0` for all SVG elements except for root `` elements and `` elements that are a direct child of a [foreignObject](/en-US/docs/Web/SVG/Element/foreignObject), and whose transform-origin is `50% 50%`, like other CSS elements. The `transform-origin` property may be specified using one, two, or three values, where each value represents an offset. Offsets that are not explicitly defined are reset to their corresponding [initial values](/en-US/docs/Web/CSS/initial_value). If a single {{cssxref("<length>")}} or {{cssxref("<percentage>")}} value is defined, it represents the horizontal offset. If two or more values are defined and either no value is a keyword, or the only used keyword is `center`, then the first value represents the horizontal offset and the second represents the vertical offset. - One-value syntax: - The value must be a {{cssxref("length")}}, or one of the keywords `left`, `center`, `right`, `top`, and `bottom`. - Two-value syntax: - One value must be a {{cssxref("length")}}, a {{cssxref("percentage")}}, or one of the keywords `left`, `center`, and `right`. - The other value must be a {{cssxref("length")}}, a {{cssxref("percentage")}}, or one of the keywords `top`, `center`, and `bottom`. - Three-value syntax: - The first two values are the same as for the two-value syntax. - The third value must be a {{cssxref("length")}}. It always represents the Z offset. ## Example This example shows the code for one PNG image and three SVG images: 1. A PNG reference image. 2. An SVG reference image that uses no transformation. 3. An SVG image that uses `transform-origin` to do a transformation, with the expected result being an image identical to the reference image. 4. An SVG image that does not use `transform-origin` but does the same transformation using just [`transform`](/en-US/docs/Web/SVG/Attribute/transform), with the expected result being an image identical to the reference image. The fourth image shows how to do the transformation in browsers that don't support `transform-origin` — because the code for the fourth image does the same transformation as the third image's `transform-origin`-based code, but by only using `transform`, without `transform-origin`. > [!NOTE] > These examples use a modified version of a code snippet in a Stack Overflow [question](https://stackoverflow.com/questions/67057190/safari-doesnt-respect-transform-origin-svg-attribute) from [Maxim Kulikov](https://stackoverflow.com/users/1033939/maxim-kulikov), as well as a modified version of a code snippet in an [answer](https://stackoverflow.com/questions/67057190/safari-doesnt-respect-transform-origin-svg-attribute/67057754) from [Michael Mullany](https://stackoverflow.com/users/271353/michael-mullany) that accompanies the question. Both code snippets are used under the terms of the [CC BY-SA](https://creativecommons.org/licenses/by-sa/4.0/) license.) ### HTML ```html

Reference image

PNG reference image
Figure 1. PNG reference image. The images following this should look exactly the same as this.
Figure 2. SVG reference image. The images following this should look exactly the same as this.

Transformation with transform-origin

Figure 3. transform-origin used. This image should look exactly the same as the reference image in Figure 2.

Transformation without transform-origin

Figure 4. transform-origin not used. This image should look exactly the same as the reference image in Figure 2.
``` ### CSS ```css h4 { font-family: sans-serif; } figure { border: thin #c0c0c0 solid; display: inline-flex; flex-flow: column; padding: 5px; max-width: 200px; margin: auto; } figcaption { margin-top: 5px; background-color: #222; color: #fff; font: smaller sans-serif; padding: 3px; text-align: center; } ``` ### Result {{ EmbedLiveSample('Example', 700, 1350) }} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}}