This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The SVGPreserveAspectRatio interface corresponds to the preserveAspectRatio attribute.
An SVGPreserveAspectRatio object can be designated as read only, which means that attempts to modify the object will result in an exception being thrown.
alignThe type of the alignment value as specified by one of the SVG_PRESERVEASPECTRATIO_* constants defined on this interface.
meetOrSliceThe type of the meet-or-slice value as specified by one of the SVG_MEETORSLICE_* constants defined on this interface.
The SVGPreserveAspectRatio interface do not provide any specific methods.
SVG_PRESERVEASPECTRATIO_UNKNOWN (0)The enumeration was set to a value that is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.
SVG_PRESERVEASPECTRATIO_NONE (1)Corresponds to value none for attribute preserveAspectRatio.
SVG_PRESERVEASPECTRATIO_XMINYMIN (2)Corresponds to value xMinYMin for attribute preserveAspectRatio.
SVG_PRESERVEASPECTRATIO_XMIDYMIN (3)Corresponds to value xMidYMin for attribute preserveAspectRatio.
SVG_PRESERVEASPECTRATIO_XMAXYMIN (4)Corresponds to value xMaxYMin for attribute preserveAspectRatio.
SVG_PRESERVEASPECTRATIO_XMINYMID (5)Corresponds to value xMinYMid for attribute preserveAspectRatio.
SVG_PRESERVEASPECTRATIO_XMIDYMID (6)Corresponds to value xMidYMid for attribute preserveAspectRatio.
SVG_PRESERVEASPECTRATIO_XMAXYMID (7)Corresponds to value xMaxYMid for attribute preserveAspectRatio.
SVG_PRESERVEASPECTRATIO_XMINYMAX (8)Corresponds to value xMinYMax for attribute preserveAspectRatio.
SVG_PRESERVEASPECTRATIO_XMIDYMAX (9)Corresponds to value xMidYMax for attribute preserveAspectRatio.
SVG_PRESERVEASPECTRATIO_XMAXYMAX (10)Corresponds to value xMaxYMax for attribute preserveAspectRatio.
SVG_MEETORSLICE_UNKNOWN (0)The enumeration was set to a value that is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.
SVG_MEETORSLICE_MEET (1)Corresponds to value meet for attribute preserveAspectRatio.
SVG_MEETORSLICE_SLICE (2)Corresponds to value slice for attribute preserveAspectRatio.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
SVGPreserveAspectRatio |
1 | 12 | 1.5 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
align |
1 | 12 | 1.5 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 4.0 | 4.4 | 1 |
meetOrSlice |
1 | 12 | 1.5 | ≤12.1 | 3 | 18 | 4 | ≤12.1 | 1 | 4.0 | 4.4 | 1 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SVGPreserveAspectRatio