SVG images can be used as an image format, in a number of contexts. Many browsers support SVG images in:
- HTML
<img>or<svg>elements - CSS
background-image
Gecko-specific contexts
Additionally, Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1) introduced support for using SVG in these contexts:
- CSS
list-style-image - CSS
content - SVG
<image>element - SVG
<feImage>element - Canvas
drawImagefunction
Restrictions
For security purposes, Gecko places some restrictions on SVG content when it's being used as an image:
- JavaScript is disabled.
- External resources (e.g. images, stylesheets) cannot be loaded, though they can be used if inlined through data: URIs.
:visited-link styles aren't rendered.- Platform-native widget styling (based on OS theme) is disabled.
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> elements.
Specifications
| Specification | Status | Comment |
|---|---|---|
| HTML5 The definition of 'SVG within <img> element' in that specification. |
Recommendation | Defines the usage of SVG within <img> elements. |
| CSS Backgrounds and Borders Module Level 3 The definition of 'SVG within 'background-image' CSS property' in that specification. |
Candidate Recommendation | Defines the usage of SVG within the background-image property. |
