The HTML <picture> element gives web developers more flexibility in specifying image resources.
The <picture> element contains one or more <source> elements, each referring to different images through the srcset attribute. This way the browser can choose the image that best fits the current view and/or device.
Each <source> element has a media attribute that defines when the image is the most suitable.
Example
Show different images for different screen sizes:
<picture>
<source media="(min-width: 650px)" srcset="/images/cat.jpg">
<source media="(min-width: 465px)" srcset="/images/computer_lab.jpg">
<img src="/images/computer_lab.jpg" style="width:auto;">
</picture>
| Live Demo & Try it yourself! | Read More » » |