Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to change the style color of svg via css

I am currently building my first website and wanted to implement some svg’s. I downloaded some and changed them up a bit with inkscape. The color for the svg is saved like this:

<path
     d="M 44.00,166.00 ..."
     style="fill:#000000;" />

is there a way to change the color with css. For example if i hover over it it changes the color?

Thanks for any help in advance

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You probably have it surrounded with <svg> so it would be something like:

<svg class='icon' [...]>
   <path d="M 44.00,166.00 ..."
     style="fill:#000000;" />
</svg>

Then you can change it with:

.icon path {
  fill: red;
}

Notice that it’s not the SVG that gets fill but path inside the SVG element.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading