vanilla-lazyload: Code for sizes without srcset is W3C-invalid

If you are validating the following code, as shown in your docs,

<img data-original="/your/image1.jpg" data-original-set="/your/image1.jpg 200w, /your/image1@2x.jpg 400w" sizes="(min-width: 20em) 35vw, 100vw">

the W3C-Validation fails, because if you are using the sizes-attributes you have to provide also a srcset attribute to be valid.

So, one possible fix would be to prefix the sizes attribute also with data- because then the validation would only see a normal <img>`with some data-attributes.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

While I agree with the idea and understand the impact, when you pass an URL to the w3c validator, it’s not the final state that is tested, but the initial one, thus returning the error related to sizes and srcset.

Customers don’t know about the difference between initial and final states when testing for the validation.