W3cubDocs

/SVG

<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 display raster image files or other SVG files.

The only image formats SVG software must support are JPEG, PNG, and other SVG files. Animated GIF behavior is undefined.

SVG files displayed with <image> are treated as an image: external resources aren't loaded, :visited styles aren'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.

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>, <discard>, <script>, <set>, <style>

Attributes

x

Positions the image horizontally from the origin. Value type: <length> | <percentage>; Default value: 0; Animatable: yes

y

Positions the image vertically from the origin. Value type: <length> | <percentage>; Default value: 0; Animatable: yes

width

The width the image renders at. Unlike HTML's <img>, this attribute is required. Value type: <length> | <percentage>; Default value: auto; Animatable: yes

height

The height the image renders at. Unlike HTML's <img>, this attribute is required. Value type: <length> | <percentage>; Default value: auto; Animatable: yes

href

Points at a URL for the image file. Value type: <URL>; Default value: none; Animatable: no

preserveAspectRatio

Controls how the image is scaled. Value type: (none | xMinYMin | xMidYMin | xMaxYMin | xMinYMid | xMidYMid | xMaxYMid | xMinYMax | xMidYMax | xMaxYMax) (meet | slice)?; Default value: xMidYMid meet; Animatable: yes

crossorigin

Defines the value of the credentials flag for CORS requests. Value type: [ anonymous | use-credentials ]?; Default value: None; Animatable: yes

decoding

Provides 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: yes

fetchpriority Experimental Non-standard

Provides a hint of the relative priority to use when fetching an external image. Allowed values:

high

Fetches the external image at a high priority relative to other external resources.

low

Fetches the external image at a low priority relative to other external resources.

auto

Doesn't set a preference for the fetch priority. It is used if no value or an invalid value is set. This is the default.

xlink:href Deprecated

Points at a URL for the image file. Value type: <URL>; Default value: none; Animatable: no

DOM Interface

This element implements the SVGImageElement 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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
image 1 12 1.5 8 3 18 4 10.1 2 1.0 3 2
crossorigin 118 118 114 104 17.2 118 114 79 17.2 25.0 118 17.2
decoding 65 79 63 52 No 65 63 47 No 9.0 65 No
fetchpriority No No 140 No No No 140 No No No No No
height 1 79 1.5 15 3 18 4 14 2 1.0 4.4 2
href 50 12 51 37 12.1 50 51 37 12.2 5.0 50 12.2
preserveAspectRatio 1 79 1.5 15 3 18 4 14 2 1.0 4.4 2
systemLanguage 1 12 12 8 3 18 14 10.1 2 1.0 3 2
width 1 79 1.5 15 3 18 4 14 2 1.0 4.4 2
x 1 79 1.5 15 3 18 4 14 2 1.0 4.4 2
xlink_href 1 79 1.5 15 3 18 4 14 2 1.0 4.4 2
y 1 79 1.5 15 3 18 4 14 2 1.0 4.4 2

See also

© 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/image