- usually requires an additional request
- can be missing from page while loading
- if fonts don't load or browser can't interpret fonts pu may get strange characters
- superior scaling
- render more quickly and reliably
- don't need to be imported from external files
- smaller in size than image formats and most icon libraries
Note: You can put them in <img>
tags, and adjust dimensions with height
and width
attributes but inlining SVGs will give you more flexibility.
<svg aria-hidden="true"><path fill="currentColor" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>
content: url(...) makes the url part into an image, in other words the svg becomes its own separate document. Styles don't apply across documents, so it's not possible to get color to affect the svg in this scenario.
When the svg is inline it is OTOH part of the document, so styles can be applied to it.
You could make (or dynamically generate) multiple versions of the checkmark svg and tune the stylerules such that the appropriate "pre-colored" one is selected.
- IcoMoon - Free and Paid options. App allows you to generate SVGs from their free gallery
- Convertio - allows you to convert other image formats to SVG files.
sources:
to read: