Let's say you have a picture element similar to this:
<picture class='my-image'>
<source media="(min-width: 1024px)" srcset="large.jpg">
<source media="(min-width: 768px)" srcset="med.jpg">
<source srcset="small.jpg">
<img src="small.jpg" alt="">
<p>Accessible text</p>
</picture>
But let's say that the context of the image is different for each breakpoint. Perhaps at large size, the picture is of a man standing in front of a tree. But at mobile size, it's just a picture of a tree.
Sometimes, certain pictures work well at mobile sizes and other pictures don't depending on page layouts, etc.
Anyways, with the picture element you can only specify the alt=
attribute in a single place for the entire picture element. But if the image context changes between each breakpoint, is it possible somehow to specify different alt=
attributes? Do you have to use JavaScript for this (which may or may not be screen reader friendly)?