I have an img tag with a src attribute referring to an icon from an external source. This icon renders as an svg. I want to change the colour of the icon to blue on hover.
The colour has to be exactly #4C8FDF, so the trick with filter on img is not working. I also prefer not to embed the svgs in the markup (I have 15 svg files, so this technique would not scale easily).
HTML:
<div class="test">
<img src="https://x.svg" alt="test">
</div>
SVG content of the icon (not visible in the DOM. only the img tag is visible in the DOM)
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path fill="#333" fill-rule="evenodd" d="M11.7 9.3c.4.4.4 1 0 1.4-.2.2-.5.3-.7.3-.2 0-.5-.1-.7-.3L8 8.4V18c0 .6-.4 1-1 1s-1-.4-1-1V8.4l-2.3 2.3c-.4.4-1 .4-1.4 0-.4-.4-.4-1 0-1.4l4-4c.1-.1.2-.2.3-.2.3-.1.5-.1.8 0 .1 0 .2.1.3.2l4 4zm10 4c.4.4.4 1 0 1.4l-4 4c-.1.1-.2.1-.3.2-.1.1-.3.1-.4.1-.1 0-.3 0-.4-.1-.1 0-.2-.1-.3-.2l-4-4c-.4-.4-.4-1 0-1.4.4-.4 1-.4 1.4 0l2.3 2.3V6c0-.6.4-1 1-1s1 .4 1 1v9.6l2.3-2.3c.4-.4 1-.4 1.4 0z"/>
</svg>
I tried referring to the icon in css to change it on hover, but this didn't work
.test img svg:hover {
fill: red;
}
Is there any other way of accessing the svg path's fill colour on hover via css?