Skip to content

Instantly share code, notes, and snippets.

@una
Last active January 14, 2016 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save una/7795fae1f8f2af919144 to your computer and use it in GitHub Desktop.
Save una/7795fae1f8f2af919144 to your computer and use it in GitHub Desktop.
Why isn't SVG <use> working
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

External <use> is not working (no image is appearing):

<svg viewBox="0 0 32 32">
  <use xlink:href="../../images/sprite.svg#service--back"></use>
</svg>

Yet, I check the path, and the path is working (yes, this is a different image):

<img src="../../images/arrow-left.svg" alt="">

The attached defs sprite is what is generated via the gulp task (using svg-sprite)

Am I missing something?

@SaraSoueidan
Copy link

The <defs><svg> should be replaced with a <symbol>, that's the first thing I noticed. Not sure if it will fix it but that's the first thing I noticed.

@SaraSoueidan
Copy link

Also, IE does not support these external SVGs in <use>, just a side note. Can you change the markup and let me know if it works then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment