Skip to main content

Timeline for How to style SVG with external CSS?

Current License: CC BY-SA 4.0

18 events
when toggle format what by license comment
Aug 17, 2023 at 5:03 comment added Mentalist @raddrick Awesome! So it's just a matter of waiting for SVG2. We should be good to go sometime in the 2050s, then. I trust the team who brought us Duke Nukem Forever is on top of it.
Jul 26, 2021 at 8:15 history edited Mahozad CC BY-SA 4.0
added 1 character in body
Oct 26, 2020 at 8:59 comment added Niklas Having a style tag as a content of the defs element is permitted. That's at least what the usage notes on Mozilla states. developer.mozilla.org/en-US/docs/Web/SVG/Element/defs
May 25, 2020 at 12:58 comment added raddrick @clayRay you will be able to do it that way once SVG2 is complete draft w3.org/TR/SVG2/styling.html#LinkElement
May 22, 2020 at 0:50 comment added clayRay shame you can't load a stylesheet inside an svg from a URL
Feb 6, 2020 at 10:05 comment added David Gausmann In my case I wanted to override element styles from the SVG. My CSS didn't work, because the element styles had a higher priority. The most simple solution was it to add an !important to the CSS style for the SVG. Then everything was fine. If you want to avoid !important, you need to move the element styles into the CSS.
Mar 30, 2017 at 17:00 comment added Ruskin Another way is to encode the SVGs as background-image data uris, with different colours on each version and rely on gzip to reduce file size due to the duplication.
May 30, 2016 at 13:41 history edited Paul D. Waite CC BY-SA 3.0
deleted 3 characters in body
Feb 6, 2015 at 10:37 comment added msg45f Does this mean that there is no method to benefit from caching the SVG and applying varied styling? Inline doesn't seem to cache well, while other methods would require creating many version of the image, eliminating any benefit from caching them.
May 3, 2014 at 17:24 history edited raddrick CC BY-SA 3.0
rails > ruby is more appropriate
May 2, 2014 at 0:20 vote accept Jordan H
Dec 21, 2013 at 16:53 history edited raddrick CC BY-SA 3.0
deleted 605 characters in body realized that some of the content was irrelevant
Dec 21, 2013 at 16:48 history edited raddrick CC BY-SA 3.0
deleted 605 characters in body
Dec 21, 2013 at 16:47 history undeleted raddrick
Dec 21, 2013 at 16:47 history deleted raddrick via Vote
Dec 21, 2013 at 16:42 history edited raddrick CC BY-SA 3.0
addressing the external file issue more deeply
Dec 21, 2013 at 16:23 history edited raddrick CC BY-SA 3.0
added 230 characters in body
Dec 21, 2013 at 16:12 history answered raddrick CC BY-SA 3.0