W3C Validator is throwing an error on the following code:
This answers only for your update:
The reason for this is, that the browser chooses one candidate from your srcset
, the src
attribute is used as a fallback. This means to get the larger candidate you need to also add it to your srcset
:
I don't really know your image layout, but I doubt, that sizes
is correct here. If this image is displayed fullwidth until 1420px your sizes attribute should look like this.
sizes="(min-width: 1420px) 1420px, 100vw"
or
sizes="(max-width: 1420px) 100vw, 1420px"
Additionally you should use more images. Note if you use the width descriptor the browser automatically handles the density for you (for retina devices). Use at least 640w, 980w/1024w, 1420w, 2048w.