<image>
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
The<image>SVG element includes images inside SVG documents. It can displayraster image files or other SVG files.
The only image formats SVG software must support areJPEG,PNG, and other SVG files. AnimatedGIF behavior is undefined.
SVG files displayed with<image> aretreated as an image: external resources aren't loaded,:visited stylesaren't applied, and they cannot be interactive. To include dynamic SVG elements, try<use> with an external URL. To include SVG files and run scripts inside them, try<object> inside of<foreignObject>.
Note:The HTML spec defines<image> as a synonym for<img> while parsing HTML. This specific element and its behavior only apply inside SVG documents or inline SVGs.
In this article
Usage context
| Categories | Graphics element, Graphics referencing element, Renderable element |
|---|---|
| Permitted content | Any number of the following elements, in any order: Animation elements Descriptive elements <animate>,<animateMotion>,<animateTransform>,<script>,<set>,<style> |
Attributes
xPositions the image horizontally from the origin.Value type:<length> |<percentage>;Default value:
0;Animatable:yesyPositions the image vertically from the origin.Value type:<length> |<percentage>;Default value:
0;Animatable:yeswidthThe width the image renders at. Unlike HTML's
<img>, this attribute is required.Value type:<length> |<percentage>;Default value:auto;Animatable:yesheightThe height the image renders at. Unlike HTML's
<img>, this attribute is required.Value type:<length> |<percentage>;Default value:auto;Animatable:yeshrefPoints at a URL for the image file.Value type:<URL>;Default value:none;Animatable:no
preserveAspectRatioControls how the image is scaled.Value type: (
none|xMinYMin|xMidYMin|xMaxYMin|xMinYMid|xMidYMid|xMaxYMid|xMinYMax|xMidYMax|xMaxYMax) (meet|slice)?;Default value:xMidYMid meet;Animatable:yescrossoriginDefines the value of the credentials flag for CORS requests.Value type: [
anonymous|use-credentials]?;Default value: None;Animatable:yesdecodingProvides a hint to the browser as to whether it should perform image decoding synchronously or asynchronously.Value type:
async | sync | auto;Default value:auto;Animatable:yesfetchpriorityExperimentalNon-standardProvides a hint of the relative priority to use when fetching an external image.Allowed values:
xlink:hrefDeprecatedPoints at a URL for the image file.Value type:<URL>;Default value:none;Animatable:no
DOM Interface
This element implements theSVGImageElement interface.
Example
Basic rendering of a PNG image in SVG:
SVG
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg"> <image href="mdn_logo_only_color.png" height="200" width="200" /></svg>Result
Specifications
| Specification |
|---|
| Scalable Vector Graphics (SVG) 2> # ImageElement> |
Browser compatibility
See also
fetchpriorityattribute