The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Tips on SVG replace using Modernizr?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #40285
    Andy Howells

    Hi all,

    I’m currently delving into the wild west of SVG images within my HTML and CSS.

    I have PNG fallbacks for each, but what I want to see is if I can use modernizr to find and replace .svg with .png

    So for example, do;

    $(document).ready(function() {
    if (!Modernizr.svg) {
    //something here //

    What I would like is to simply grab the .svg ending and switch it out for .png if SVG isn’t supported, but I’m useless at JS.

    The images themselves are inside simple img tags.

    Re: the CSS swap, I’m probs going to make an IE style sheet with all the PNG’s instead, but are there any shortcut methods you guys use for this?


    @andy_unleash Right. I don’t see why you would want to go that route. IE9+ supports SVG with `` tag. When it comes to those who don’t support it, you can change out the extension to png. Doing it your way, I assume, would cause more http requests to grab those SVG images.


    @andy_unleash Take a look at this

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.