Reputation: 97
I was reading about svg icons here https://css-tricks.com/svg-sprites-use-better-icon-fonts/
but the author doesn't mention if it's possible to separate the icon part from the content, like it is with web fonts. Are SVGs always required to be present in the HTML code? Can they be included in the CSS styles instead?
Upvotes: 0
Views: 79
Reputation: 923
If you call an svg as you would a normal image you can use it in css e.g.
.myDiv{background: url(path/to/mySvg.svg) center center;}
The downside to this method is you can't adjust fill/stroke colours for the SVG like you can when the svg code is embedded directly in the html (i.e. not called from the src
of an img
element)
Upvotes: 1