# Bad value X for attribute “srcset” on element “source”: Expected number followed by “w” or “x” but found Y at Z.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-for-attribute-srcset-on-element-source-expected-number-followed-by-w-or-x-but-found-y-at-z
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

A `srcset` attribute on a `<source>` element inside a `<picture>` requires each image URL to be paired with a width descriptor (`w`) or a pixel density descriptor (`x`).

The `srcset` attribute differs from the `src` attribute. While `src` accepts a bare URL, `srcset` expects one or more image candidates, where each candidate is a URL followed by a space and a descriptor. When no descriptor is provided, the W3C validator rejects the value because it cannot determine how the browser should select the image.

A width descriptor like `600w` tells the browser the intrinsic width of the image in pixels. A pixel density descriptor like `1x` or `2x` indicates the intended display density. If you only have a single image and don't need responsive selection, you can still satisfy the validator by appending a descriptor.

When `<source>` is used inside `<picture>`, the `srcset` attribute is required instead of `src`. This is defined in the HTML specification: the `<source>` element within `<picture>` does not support `src`.

## Invalid example

```html
<picture>
  <source type="image/webp" srcset="/images/img01.webp">
  <img src="/images/img01.jpg" alt="A sample image" width="600" height="400">
</picture>
```

## Valid examples

Add a width descriptor to each entry in `srcset`:

```html
<picture>
  <source
    type="image/webp"
    srcset="/images/img01-600.webp 600w, /images/img01-1200.webp 1200w"
    sizes="(max-width: 600px) 100vw, 600px">
  <img src="/images/img01.jpg" alt="A sample image" width="600" height="400">
</picture>
```

If you have a single image and no responsive variants, use a pixel density descriptor:

```html
<picture>
  <source type="image/webp" srcset="/images/img01.webp 1x">
  <img src="/images/img01.jpg" alt="A sample image" width="600" height="400">
</picture>
```
