Skip to main content

HTML Guide

Bad value X for attribute “sizes” on element “img”: Empty source size at Y.

The sizes attribute contains an empty source size, probably due to a trailing comma.

According to the HTML standard, the sizes attribute on the img element must contain a valid source size list. Each size is separated by a comma, and there must not be a trailing comma because that would create an empty entry, which is not allowed.

An example of an invalid sizes attribute:

<img
  src="image.jpg"
  alt=""
  sizes="(min-width: 2200px) 100vw, (min-width: 856px) 461px, (min-width: 784px) 615px, "
  srcset="image-2200.jpg 2200w, image-856.jpg 856w">

To fix the validation error, remove the trailing comma so the size list does not end with an empty value:

<img
  src="image.jpg"
  alt=""
  sizes="(min-width: 2200px) 100vw, (min-width: 856px) 461px, (min-width: 784px) 615px"
  srcset="image-2200.jpg 2200w, image-856.jpg 856w">

Each value in the sizes attribute should be a valid media condition and source size, separated only by commas, with no trailing or empty values.

Learn more:

Related W3C validator issues