Example
You can render the contents of an SVG file as an image within an HTML document using an <img>
tag. For example:
<img src="my_svg_file.svg" alt="Image description">
The dimensions of the image will, by default, display according to the width and height properties specified in the SVG file referenced in the src
attribute.
It's worth noting various limitations inherent in this approach:
- Browser support, whilst good, doesn't include Internet Explorer 8 and earlier versions, nor Android 2.3 and earlier versions.
- You can't style the individual elements contained within the SVG file using CSS which is external to the SVG file. All CSS must be within the image file itself.
- JavaScript won't run.
- The image must be complete in a single file. For example, if the SVG file contains raster images then those internal images must be encoded as data URLs.