A quick introduction to SVG icon and different ways to use them: separate files or embedded in the HTML.
SVG icons
Makes for a great icon sets
A separate file is usually better for performance & maintenance because it can be shared, edited and reused.
<!-- At the top of the HTML --> <svg hidden> <symbol id="the-circle" viewBox="0 0 48 48"> <circle cx="24" cy="24" r="22" fill="tomato" /> </symbol> <symbol id="the-triangle" viewBox="0 0 48 48"> <polygon points="24,2 46,46 2,46" fill="yellowgreen" /> </symbol> </svg> <!-- Further down the HTML --> <i class="icon i-128"> <svg><use xlink:href="#the-triangle"></use></svg> </i> <i class="icon i-128"> <svg><use xlink:href="#the-circle"></use></svg> </i> <i class="icon i-24"> <svg><use xlink:href="#the-triangle"></use></svg> </i>
<!-- Icons in a separate sprite sheet --> <i class="icon i-96"> <svg><use xlink:href="images/icons.svg#the-circle"></use></svg> </i> <i class="icon i-128"> <svg><use xlink:href="images/icons.svg#the-triangle"></use></svg> </i> <i class="icon i-48"> <svg><use xlink:href="images/icons.svg#the-circle"></use></svg> </i>
<!-- No `fill` attributes in the symbol --> <svg hidden> <symbol id="the-circle" viewBox="0 0 48 48"> <circle cx="24" cy="24" r="22" /> </symbol> </svg> <i class="icon i-128"> <svg><use xlink:href="#the-circle"></use></svg> </i>
.icon { color: tomato; transition: all .25s linear; } .icon:hover { color: orange; }
Use Spritebot to combine different SVG graphics into a sprite sheet