1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
---
title: image
slug: Web/SVG/Element/image
tags:
- Elemento
- Gráficos SVG
- Referencia
- SVG
translation_of: Web/SVG/Element/image
---
<div>{{SVGRef}}</div>
<p>O elemento SVG <code><strong><image></strong></code> carrega imagens dentro de documentos SVG. Ele pode exibir arquivos {{glossary("raster image")}} ou outros arquivos SVG.</p>
<p>The only image formats SVG software must support are <a href="/en-US/docs/Glossary/jpeg">JPEG</a>, <a href="/en-US/docs/Glossary/PNG">PNG</a>, and other SVG files. Animated <a href="/en-US/docs/Glossary/gif">GIF</a> behavior is undefined.</p>
<p>SVG files displayed with <code><image></code> are <a href="/en-US/docs/Web/SVG/SVG_as_an_Image">treated as an image</a>: external resources aren't loaded, <a href="/en-US/docs/Web/CSS/:visited">:visited</a> styles <a href="/en-US/docs/Web/CSS/Privacy_and_the_:visited_selector">aren't applied</a>, and they cannot be interactive. To include dynamic SVG elements, try <a href="/en-US/docs/Web/SVG/Element/use"><use></a> with an external URL. To include SVG files and run scripts inside them, try <a href="/en-US/docs/Web/HTML/Element/object"><object></a> inside of <a href="/en-US/docs/Web/SVG/Element/foreignObject"><foreignObject></a>.</p>
<div class="note">
<p><strong>Note:</strong> The HTML spec defines <code><image></code> as a synonym for <a href="/en-US/docs/Web/HTML/Element/img"><img></a> while parsing HTML. This specific element and its behavior only apply inside SVG documents or <a href="/en-US/docs/SVG_In_HTML_Introduction">inline SVG</a>.</p>
</div>
<h2 id="Usage_context">Usage context</h2>
<p>{{svginfo}}</p>
<h2 id="Attributes">Attributes</h2>
<h3 id="Global_attributes">Global attributes</h3>
<ul>
<li><a href="/en-US/docs/Web/SVG/Attribute#Conditional_processing_attributes">Conditional processing attributes</a></li>
<li><a href="/en-US/docs/Web/SVG/Attribute#Core_attributes">Core attributes</a></li>
<li><a href="/en-US/docs/Web/SVG/Attribute#Graphical_event_attributes">Graphical event attributes</a></li>
<li><a href="/en-US/docs/Web/SVG/Attribute#Presentation_attributes">Presentation attributes</a></li>
<li><a href="/en-US/docs/Web/SVG/Attribute#Xlink_attributes">Xlink attributes</a></li>
<li>{{SVGAttr("class")}}</li>
<li>{{SVGAttr("style")}}</li>
<li>{{SVGAttr("externalResourcesRequired")}}</li>
<li>{{SVGAttr("transform")}}</li>
</ul>
<h3 id="Specific_attributes">Specific attributes</h3>
<ul>
<li>{{SVGAttr("x")}}: Positions the image horizontally from the origin.</li>
<li>{{SVGAttr("y")}}: Positions the image vertically from the origin.</li>
<li>{{SVGAttr("width")}}: The width the image renders at. Unlike HTML's <code><img></code>, this attribute is required.</li>
<li>{{SVGAttr("height")}}: The height the image renders at. Unlike HTML's <code><img></code>, this attribute is required.</li>
<li>{{SVGAttr("href")}} and {{SVGAttr("xlink:href")}}: Points at a URL for the image file.</li>
<li>{{SVGAttr("preserveAspectRatio")}}: Controls how the image is scaled.</li>
</ul>
<h2 id="DOM_Interface">DOM Interface</h2>
<p><code><image></code> implements the {{domxref("SVGImageElement")}} interface.</p>
<h2 id="Example">Example</h2>
<p>Basic rendering of a PNG image in SVG:</p>
<h3 id="SVG">SVG</h3>
<pre class="brush: html"><svg width="200" height="200"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<image href="https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png" height="200" width="200"/>
</svg>
</pre>
<h3 id="Result">Result</h3>
<p>{{EmbedLiveSample("Example", 250, 260)}}</p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('SVG2', 'embedded.html#ImageElement', '<image>')}}</td>
<td>{{Spec2('SVG2')}}</td>
<td>Allows omitting <code>height</code> and <code>width</code></td>
</tr>
<tr>
<td>{{SpecName('SVG1.1', 'struct.html#ImageElement', '<image>')}}</td>
<td>{{Spec2('SVG1.1')}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Compatibilidade com navegadores</h2>
<p>{{Compat("svg.elements.image")}}</p>
|