You could create your own SVG font, there are online tools for that like Fontello
A note to SVG Font compatibility (thanks to @herrstrietzel)
SVG font's are deprecated and only supported by older browsers and Safari. To make sure your font's are working, also include WOFF(2) and / or TTF files in your font face for maximum compatibility. Fontello is already providing them, but there are other converters available in case you only have it as svg.
Create a new font-face
for it in CSS, you actually get the CSS code from the generator ready to copy & paste as well as some other usefull CSS to have ready to use classes.
@font-face {
font-family: 'your-font-name';
src: url('../font/your-font-name.eot?34609786');
src: url('../font/your-font-name.eot?34609786#iefix') format('embedded-opentype'),
url('../font/your-font-name.woff2?34609786') format('woff2'),
url('../font/your-font-name.woff?34609786') format('woff'),
url('../font/your-font-name.ttf?34609786') format('truetype'),
url('../font/your-font-name.svg?34609786#fontello') format('svg');
font-weight: normal;
font-style: normal;
}
[class^="icon-"]:before, [class*=" icon-"]:before {
font-family: "fontello";
font-style: normal;
font-weight: normal;
speak: never;
/* More properties here, i removed them */
}
.icon-download:before { content: '\e804'; }
Each icon gets it's own code, so you can have a ton of different SVGs in your font.
Then you can use it in CSS :after
and :before
as content: '\e800';
(e800 is just an example, may be different for you).
Having that in your CSS, in your HTML you could then use it as following:
<div>
<i class="icon icon-download"></i>
</div>
<section id="el2">
<i class="icon icon-download"></i>
</section>
<div id="el3">
<i class="icon icon-download"></i>
</div>
<p id="el4">
<i class="icon icon-download"></i>
</p>
So overall you end up with less code in your html and the user only has to download the SVG once via the Font.
And also a huge plus, new icons are added extremely fast this way.