Skip to main content

HTML Guide

Bad value “” for attribute “sizes” on element “img”: Must not be empty.

An empty sizes attribute on an img element is invalid; the attribute must contain a valid value or be omitted.

The sizes attribute specifies the slot width that the browser should use for selecting the appropriate image from those available in srcset. It should only be used when the srcset attribute is present. An empty string is not a valid value—if you do not have any sizes to specify, the attribute should be removed entirely.

Correct usage:

  • Remove the empty sizes and srcset attributes if not needed.
  • If specifying, provide valid values such as "100vw" or "(max-width: 600px) 100vw, 50vw".

Incorrect example:

<img src="photo.jpg" srcset="photo-small.jpg 480w, photo-large.jpg 1200w" sizes="" alt="">

Corrected example (with a valid sizes value):

<img src="photo.jpg" srcset="photo-small.jpg 480w, photo-large.jpg 1200w" sizes="100vw" alt="">

Learn more:

Related W3C validator issues