Should I use ,
, or
for loading SVG files into a page in a way similar to loading a
jpg>
If you need your SVGs to be fully styleable with CSS they have to be inline in the DOM. This can be achieved through SVG injection, which uses Javascript to replace a HTML element (usually an element) with the contents of an SVG file after the page has loaded.
Here is a minimal example using SVGInject:
After the image is loaded the onload="SVGInject(this)
will trigger the injection and the element will be replaced by the contents of the file provided in the
src
attribute. This works with all browsers that support SVG.
Disclaimer: I am the co-author of SVGInject