Skip to main content

Timeline for How to style SVG with external CSS?

Current License: CC BY-SA 4.0

7 events
when toggle format what by license comment
Jul 18, 2021 at 21:52 comment added BarryCap As said by Moose Morals, with this method, we cannot use an <img> tag and load external CSS inside SVG; I would therefore recommend the use of <object>, with the data attribute instead of the src.
Feb 11, 2021 at 13:10 comment added Armen Michaeli @Frans everything you remarked applies the same way to HTML, so this isn't SVG-specific. In fact it's a very general linking problem -- there are indeed both benefits and drawbacks to mark up links between documents.
Aug 15, 2020 at 13:41 comment added Moose Morals Note that svg loaded through an <img> tag will not load external content (e.g., stylesheets).
Aug 14, 2020 at 12:04 comment added Frans The whole point is centralizing your style definitions. Let's say you have 10 SVGs you want to style. Now you need to copy in a reference to the CSS into all the SVGs that need to be affected. And if the file name / location of your CSS changes, you need to update it in 10 SVGs. A CSS class feels a lot more symbolic than a reference to a physical CSS file.
Dec 28, 2019 at 21:45 review Late answers
Dec 28, 2019 at 21:45
Dec 28, 2019 at 21:30 review First posts
Dec 28, 2019 at 23:16
Dec 28, 2019 at 21:25 history answered Jacek Mamot CC BY-SA 4.0