Now I'm trying t...">

Change svg image color with CSS

I have the following svg image in my html file:

<img class="svg" src="my-image-link.svg">

Now I'm trying to change the color using this css code:

.svg path {
    fill: black;
}

However, nothing is changing. What is the correct way to change the color of the path of an SVG image using css? Thank!

+4
source share
2 answers

if you use svg in the image tag, it is impossible to change anything in SVG ...

to do this, you must enable all SVG inline ... look here: link

+4
source

You should use the built-in SVG, where the path element is inside the HTML, as opposed to referencing an external SVG.

: https://jsfiddle.net/fznuckb0/1/

.path-name {
    fill: tomato;
    fill-rule: evenodd;
}
+3

Source: https://habr.com/ru/post/1659413/


All Articles