# Bad value X for attribute “imagesrcset” on element “link”: No width specified for image Y. (When the “sizes” attribute is present, all image candidate strings must specify a width.)

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-for-attribute-imagesrcset-on-element-link-no-width-specified-for-image-y-when-the-sizes-attribute-is-present-all-image-candidate-strings-must-specify-a-width
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

A `<link>` element has an `imagesizes` attribute, but at least one URL in its `imagesrcset` has no width descriptor such as `800w`.

`imagesrcset` and `imagesizes` are the preload versions of the `srcset` and `sizes` attributes of `<img>`. On a `<link rel="preload" as="image">`, they let the browser start downloading the same file that the `<img>` will pick later.

`imagesizes` says how wide the image will be in the layout, and the browser compares that width with the `w` descriptor of each candidate to choose one. A URL with no descriptor gives it no width to compare, so when `imagesizes` is present, every candidate needs one. The message names "sizes" because the validator reuses its `<img>` wording.

This can come from a theme or plugin that preloads the main image of a page by copying the image's `srcset` into `imagesrcset`. When the image exists in only one size, that copy is a bare URL, but the plugin still prints `imagesizes`.

To fix it, add the width of each image file in pixels after its URL, as in `hero.jpg 800w`. If you preload a single file, you can also remove `imagesrcset` and `imagesizes` and put the URL in `href` instead. Density descriptors such as `2x` won't work here either: next to `imagesizes`, the validator reports them as a different error.

## Invalid example

```html
<link
  rel="preload"
  as="image"
  imagesrcset="hero.jpg"
  imagesizes="(max-width: 800px) 100vw, 800px">
```

## Valid example

```html
<link
  rel="preload"
  as="image"
  imagesrcset="hero.jpg 800w"
  imagesizes="(max-width: 800px) 100vw, 800px">
```
