Is setting the width and height of an SVG important for indexing?

by cute_ptr   Last Updated October 11, 2018 11:04 AM

Generally, when SVGs are displayed responsively, we only need to set the viewBox attribute on the <svg> and can entirely omit the width and height attributes. So I wondered how SVG images with width and height attributes omitted were indexed by a search engine like Google, i.e. what size would they be displayed in Image Search. After a little bit of searching, it turned out that they are displayed as follows:

  • if width is bigger than height, width is 800px and height is set to preserve the aspect ratio
  • if height is bigger than width, height is 800px and width is set to preserve the aspect ratio

On the other hand, SVG images with width and height attributes set seem to be displayed in Image Search with the size as indicated in the two attributes (e.g. an SVG with width and height of 100px will be displayed as 100x100).

I also found an SVG image whose width and height are set to 100%, and it is displayed as 2000x2000 in Image Search.

So, what is the best practice for the width and height attributes of SVG images? Should they be omitted, set to 100%, or set to some other particular size?

Related Questions

Images are blurry in one category and not the other

Updated April 18, 2015 20:01 PM

Prevent indexing of image or file

Updated February 19, 2017 17:04 PM