Set img.src to dynamic svg element
You can do this using JavaScript:
var svg = document.querySelector('svg'), img = document.querySelector('img'); setImageToSVG(img,svg); function setImageToSVG(img,svg){ var xml = (new XMLSerializer).serializeToString(svg); img.src = "data:image/svg+xml;charset=utf-8,"+xml; }β If your SVG element is dynamic (change), you will need to re-run this code every time the SVG element has changed.
Demo: http://jsfiddle.net/3PfcC/
Alternatively, here's a demo showing @Robert's answer using another <svg> element to reference the first, live:
Demo: http://jsfiddle.net/3PfcC/3/
<svg id="src" xmlns="http://www.w3.org/2000/svg" β¦> <!-- Your SVG here --> </svg> <svg xmlns="http://www.w3.org/2000/svg" xmlns:x="http://www.w3.org/1999/xlink" β¦> <use x:href="#src" x="80" y="30" width="100" height="100" /> </svg> The demo also shows that you can resize and otherwise transform the SVG document that is referenced, and that the link is active: changes to the original are immediately reflected in <use> .