Can I change the fill color of an svg path with CSS?

The Solution to Can I change the fill color of an svg path with CSS? is


Yes, you can apply CSS to SVG, but you need to match the element, just as when styling HTML. If you just want to apply it to all SVG paths, you could use, for example:

?path {
    fill: blue;
}?

External CSS appears to override the path's fill attribute, at least in WebKit and Gecko-based browsers I tested. Of course, if you write, say, <path style="fill: green"> then that will override external CSS as well.

~ Answered on 2012-03-02 07:17:45


Most Viewed Questions: