Premise: I have done a lot of research on how img
and source
tags work, but every single article only superficially deals with the attributes of these tags.
I need to make sure that if the browser does not support the image format (eg .wepb
, but it can be .raw
or .nef
), or the path/url is wrong, there is a correct fallback to a .jpg
, then to the alt
. I thought of these two solutions:
<!-- First solution -->
<img src="foo.jpg" alt="foo"
srcset="foo.webp 1x">
<!-- Second solution -->
<picture>
<source srcset="bar.webp">
<img src="bar.jpg" alt="bar">
</picture>
Neither of them works, in fact if the file is not found, or if I try with unsupported extensions, there is no fallback on src
, but the alt
is triggered instead.