Add Icons Using SVG Sprites

Want the wonderful goodness of SVG without having the need for our SVG + JS framework at the moment? Have no fear, SVG Sprites are here. But, ahem, this technique has some issues in general, so make sure they'll work for your project.

First Things First!

Make sure you’ve got the right files from Font Awesome Alpha zip in your project and are ready to manage some mischief.

# Basic Use

  1. Grab one of the sprite files.
  2. Place this file with the rest of your static files, like CSS or images, in your project.
  3. In the body of your document call the individual icon you want to use.
<header>
  <ul>
    <li>
      <a href="https://facebook.com/fontawesome">
        <svg>
          <use xlink:href="fa-brands.svg#facebook"></use>
        </svg>
      </a>
    </li>
    <li>
      <a href="https://twitter.com/fontawesome">
        <svg>
          <use xlink:href="fa-brands.svg#twitter"></use>
        </svg>
      </a>
    </li>
    <li>
      <a href="https://github.com/FortAwesome/Font-Awesome">
        <svg>
          <use xlink:href="fa-brands.svg#github"></use>
        </svg>
      </a>
    </li>
  </ul>
</header>

# Issues with SVG sprites

SVG sprites have a few tricky points you need to know about. Make sure your project is a good fit for using this technique with the following in mind.

Same origin policy

If you use URLs in the xlink:href they need to be loaded from the same domain. There is cross-origin protection on SVGs loaded this way. Some people just serve it directly from their static assets. You can also use a proxy.

Internet Explorer doesn't load remote SVGs

If you use a URL in the xlink:href IE will not automatically download the file for you. Check out this project if this is something you need.

Something on your mind? We're all ears!

New icons just what you wanted? New thin style all that? Docs missing something key? Drop us a line and tell us all the good, bad and the ugly so we can make it even more awesome.

Manufacturers Protocol dictates this alpha cannot be captured. It must self-destruct.