Skip to main content
The 2024 Developer Survey results are live! See the results
deleted 3 characters in body
Source Link
Penny Liu
  • 16.8k
  • 5
  • 84
  • 106

Yes, you can apply CSS to SVG, but you need to match the element, just as when styling HTML. IfIf 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.

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.

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.

Source Link
Nicholas Riley
  • 44.1k
  • 6
  • 103
  • 125

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.