This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2018.
* Some parts of this feature may have varying levels of support.
The <view> SVG element defines a particular view of an SVG document. A specific view can be displayed by referencing the <view> element's id as the target fragment of a URL.
| Categories | None |
|---|---|
| Permitted content | Any number of the following elements, in any order: Descriptive elements |
preserveAspectRatioThis attribute defines how the SVG fragment must be deformed if it is embedded in a container with a different aspect ratio. Value type: (none | xMinYMin | xMidYMin | xMaxYMin | xMinYMid | xMidYMid | xMaxYMid | xMinYMax | xMidYMax | xMaxYMax) (meet | slice)?; Default value: xMidYMid meet; Animatable: yes
viewBoxThis attribute defines the bound of the SVG viewport for the pattern fragment. Value type: <list-of-numbers>; Default value: none; Animatable: yes
zoomAndPan Deprecated
This attribute specifies whether the SVG document can be magnified and panned. Value type: disable | magnify; Default value: magnify; Animatable: no
This element implements the SVGViewElement interface.
<svg viewBox="0 0 300 100" width="300" height="100"
xmlns="http://www.w3.org/2000/svg">
<view id="one" viewBox="0 0 100 100" />
<circle cx="50" cy="50" r="40" fill="red" />
<view id="two" viewBox="100 0 100 100" />
<circle cx="150" cy="50" r="40" fill="green" />
<view id="three" viewBox="200 0 100 100" />
<circle cx="250" cy="50" r="40" fill="blue" />
</svg>
<img src="example.svg" alt="three circles" width="300" height="100" /> <br /> <img src="example.svg#three" alt="blue circle" width="100" height="100" />
| Specification |
|---|
| Scalable Vector Graphics (SVG) 2> # ViewElement> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
view |
1 | ≤18 | 15 | 15 | 3 | 18 | 15 | 14 | 2 | 1.0 | 4.4 | 2 |
preserveAspectRatio |
1 | 79 | 15 | 15 | 3 | 18 | 15 | 14 | 2 | 1.0 | 4.4 | 2 |
viewBox |
1 | 79 | 15 | 15 | 3 | 18 | 15 | 14 | 2 | 1.0 | 4.4 | 2 |
zoomAndPan |
1 | 79 | 15 | 15 | 3 | 18 | 15 | 14 | 2 | 1.0 | 4.4 | 2 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/view