files/en-us/web/svg/reference/attribute/gradientunits/index.md
The gradientUnits attribute defines the coordinate system used for attributes specified on the gradient elements.
You can use this attribute with the following SVG elements:
For {{SVGElement("linearGradient")}}, gradientUnits defines the coordinate system used for the attributes {{SVGAttr("x1")}}, {{SVGAttr("y1")}}, {{SVGAttr("x2")}}, and {{SVGAttr("y2")}}.
userSpaceOnUse
objectBoundingBox
: This value indicates that the user coordinate system for the attributes is established using the bounding box of the element to which the gradient is applied and then applying the transform specified by attribute gradientTransform.
Percentages represent values relative to the bounding box for the object.
With this value and gradientTransform being the identity matrix, the normal of the linear gradient is perpendicular to the gradient vector in object bounding box space (i.e., the abstract coordinate system where (0,0) is at the top/left of the object bounding box and (1,1) is at the bottom/right of the object bounding box). When the object's bounding box is not square, the gradient normal which is initially perpendicular to the gradient vector within object bounding box space may render non-perpendicular relative to the gradient vector in user space. If the gradient vector is parallel to one of the axes of the bounding box, the gradient normal will remain perpendicular. This transformation is due to application of the non-uniform scaling transformation from bounding box space to user space.
For {{SVGElement("radialGradient")}}, gradientUnits defines the coordinate system used for the attributes {{SVGAttr("cx")}}, {{SVGAttr("cy")}}, {{SVGAttr("r")}}, {{SVGAttr("fx")}}, {{SVGAttr("fy")}}, and {{SVGAttr("fr")}}.
userSpaceOnUse
objectBoundingBox
gradientTransform.
With this value and gradientTransform being the identity matrix, the rings of the radial gradient are circular with respect to the object bounding box space (i.e., the abstract coordinate system where (0,0) is at the top/left of the object bounding box and (1,1) is at the bottom/right of the object bounding box). When the object's bounding box is not square, the rings that are conceptually circular within object bounding box space will render as elliptical due to application of the non-uniform scaling transformation from bounding box space to user space.{{Specifications}}
{{Compat}}