Skip to content

Instantly share code, notes, and snippets.

@iamkevingreen
Created August 16, 2013 18:14
Show Gist options
  • Save iamkevingreen/6252180 to your computer and use it in GitHub Desktop.
Save iamkevingreen/6252180 to your computer and use it in GitHub Desktop.
SVG Fallbacks
<svg width="96" height="96">
<image xlink:href="svg.svg" src="svg.png" width="96" height="96"/>
</svg>
And here the magic: browsers which support SVG will read the code as:
<svg width="96" height="96">
<image xlink:href="svg.svg" width="96" height="96"/>
</svg>
ignoring src attribute and will show SVG image.
Browsers which do not support SVG will ignore unknown tag svg and thanks to image is replaced with img will read the code as:
<img src="svg.png" width="96" height="96"/>
and will show regular image.
For very simple images (e.g. icons), it is possible not to create a separate SVG file, just write all the content in HTML, that could be shorter than the file path.
<svg height="16" width="16">
<path d="M5 1v14l9-7">
<image src="next.png">
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment