What are the advantages of embedding SVG as an <img> element instead of as an <image> embedded in SVG?

31 views Asked by At

Let's assume I have an SVG file here that is to be embedded in the HTML of a website (not inline!).

Obviously there are two common ways to do this:

  1. Directly as <img> tag:

    <img alt="" title="SVG Title" src="svgFile.svg" width="24" height="24" />
    
  2. As <image> embedded in the SVG element:

    <svg viewBox="0 0 24 24">
      <title>SVG Title</title>
      <image width="24" height="24" href="svgFile.svg" />
    </svg>
    

What are the advantages/disadvantages of the different possibilities?

I have tried both options, but have not noticed any obvious differences myself. Have I missed something?

0

There are 0 answers