SVG images can be used as an image format, in a number of contexts. Many browsers support SVG images in:
<img>
or
<svg>
元素
background-image
Additionally, Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1) introduced support for using SVG in these contexts:
list-style-image
content
<image>
element
<feImage>
element
drawImage
function
For security purposes, Gecko places some restrictions on SVG content when it's being used as an image:
:visited
-link styles aren't rendered.
Note that the above restrictions are specific to image contexts; they don't apply when SVG content is viewed directly, or when it's embedded as a document via the
<iframe>
,
<object>
, or
<embed>
元素。
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML5
The definition of 'SVG within <img> element' in that specification. |
推荐 |
Defines the usage of SVG within
<img>
元素。
|
|
CSS Backgrounds and Borders Module Level 3
The definition of 'SVG within 'background-image' CSS property' in that specification. |
候选推荐 |
Defines the usage of SVG within the
background-image
特性。
|
最后修改: , 由 MDN 贡献者