When utilising SVGs in your HTML, you may find yourself inserting them using the img tag. This is nice and clean and keeps them formatted and styled in the same way as your other images…
However, this adds a limitation to your ability to dynamically style them.
Html:
<img
...other properties
src = "tractor.svg"
/>
If you’re working in a Javascript framework (In my case, React), you might also choose to do it by parsing the file directly into a data string within the image tag. This can help you turn a multi-file project into a single output file, but it still runs into the same drawback as above.
React:
<img
...other properties
src = {`data:image/svg+xml;utf8,${encodeURIComponent(tractor.svg)}`}
/>
