href apparently not required on preload imagesrcset LINK

For technical support and bug reports for all editions of CSS HTML Validator, including htmlval for Linux and Mac.
TomHTML
Rank III - Intermediate
Posts: 75
Joined: Sun Feb 04, 2018 10:19 am

href apparently not required on preload imagesrcset LINK

Post by TomHTML »

The HTML specs on the rel=preload imagesrcset LINK element found here:

https://html.spec.whatwg.org/multipage/ ... magesrcset

...includes this example:
These attributes allow preloading the appropriate resource that is later used by an img element that has the corresponding values for its srcset and sizes attributes:

Code: Select all

<link rel="preload" as="image"
      imagesrcset="wolf_400px.jpg 400w, wolf_800px.jpg 800w, wolf_1600px.jpg 1600w"
      imagesizes="50vw">

<!-- ... later, or perhaps inserted dynamically ... -->
<img src="wolf.jpg" alt="A rad wolf"
     srcset="wolf_400px.jpg 400w, wolf_800px.jpg 800w, wolf_1600px.jpg 1600w"
     sizes="50vw">
Note how we omit the href attribute, as it would only be relevant for browsers that do not support imagesrcset, and in those cases it would likely cause the incorrect image to be preloaded.
The last sentence indicates that no `href` belongs on this LINK element. However, when I attempt to validate it with the validator, it issues this error:
The "link" element requires the "href" attribute to specify the link. This is an HTML5 requirement.
Unless the spec quoted above has been revised, it looks like the validator shouldn't count this type of LINK without an `href` as erroneous HTML.
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: href apparently not required on preload imagesrcset LINK

Post by Albert Wiersch »

Hello,

Thank you. The HTML5 spec now says this for the "link" element:
One or both of the href or imagesrcset attributes must be present.
I've fixed this in the latest config file which is available here:
https://www.htmlvalidator.com/2021/htmlvalV210cfg.zip

Please see the "readme" file in the above ZIP file for installation instructions.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
TomHTML
Rank III - Intermediate
Posts: 75
Joined: Sun Feb 04, 2018 10:19 am

Re: href apparently not required on preload imagesrcset LINK

Post by TomHTML »

Thanks! I can confirm it works for my site code. And it identified a few images that were misnamed in the imagesrcset listing that I wouldn't have caught otherwise (it reported a 404 when trying to retrieve them...fantastic!)
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: href apparently not required on preload imagesrcset LINK

Post by Albert Wiersch »

TomHTML wrote: Sun Oct 10, 2021 3:59 pm Thanks! I can confirm it works for my site code. And it identified a few images that were misnamed in the imagesrcset listing that I wouldn't have caught otherwise (it reported a 404 when trying to retrieve them...fantastic!)
Great! :D
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial