Using SVG with PNG is returned in img tags depending on the browser without javascript or PHP

I know there are several topics on this, but ultimately all the answers seem to suggest using modernizr or some javascript code. I think the biggest reason to enable png reserve for IE8 and below. I was wondering why no one seems to be using the following code.

<!--[if lt IE 9]><img src="img.png" /><![endif]--> <!--[if gt IE 8]><img src="img.svg" /><!--<![endif]--> 

The first question is, is it bad? Is the standard way to use modernizr and javascript?

The second question, I noticed that the second line seems to be shown for other browsers, such as Chrome and Firefox, next to IE 9 and IE 10. This is exactly the behavior I wanted, but it seems weird. Is this supposed to be so?

Third question: I googled and cannot find a place where all comment functions are explained, such as [if ...]. Are there any other functions besides [if ...]? Is there any [if ... then]?

+4
source share
1 answer

You tried:

 <object data="img.svg" width="200px" height="50px" type="image/svg+xml"> <img src="img.png" width="200" height="50"> </object> 
+2
source

Source: https://habr.com/ru/post/1501588/


All Articles