# Bad value X for attribute “srcset” on element “source”: Width for image Y is identical to width for image Z.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-for-attribute-srcset-on-element-source-width-for-image-y-is-identical-to-width-for-image-z
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

Each image candidate in a `srcset` attribute needs its own width descriptor, so two candidates cannot share the same `w` value.

The browser combines the width descriptors with the `sizes` attribute to pick the file that best fits the layout. When two candidates have the same width, the browser has no way to tell them apart, so it keeps the first one and drops the other. The second file is never downloaded. The HTML standard forbids duplicate width descriptors, and the validator names the two image URLs that share the value. Long `srcset` values are left out of the message, which is why it can start with `Bad value  for` and an empty value.

A CMS or build script that writes resized copies of an image often causes this. If it takes the descriptors from the original file instead of from each copy, and the original is smaller than the largest size requested, several copies end up labeled with the original's width.

To fix it, make each descriptor match the real pixel width of its file. If two entries point to files of the same width, or a larger file is only an upscaled copy of a smaller one, remove the extra entry. The same rule applies to `srcset` on `<img>`.

## Invalid example

Both candidates claim a width of `800w`, although the second file is 1200 pixels wide:

```html
<picture>
  <source srcset="photo-800.webp 800w, photo-1200.webp 800w" sizes="100vw">
  <img src="photo-800.jpg" alt="A field at sunset">
</picture>
```

## Valid example

Each descriptor now matches the width of its file:

```html
<picture>
  <source srcset="photo-800.webp 800w, photo-1200.webp 1200w" sizes="100vw">
  <img src="photo-800.jpg" alt="A field at sunset">
</picture>
```
