0

In a browser, can the color of an SVG icon be changed with CSS or JavaScript?

ken
  • 1

1 Answers1

2

If the SVG is declared directly in HTML, then yes, you can add styles to different SVG elements, as you do any other HTML element on the page.

If it's the link to an SVG file, then it's interpreted as an ordinary image, similarly to PNG, so you can't do it easily. You may on the other hand be interested by CSS 3's filter attribute.

Arseni Mourzenko
  • 50,338
  • 35
  • 112
  • 199