HTML <picture> Tag
- The HTML
<picture>
tag is used to include different image sources and their respective sizes for different device screen sizes or resolutions in a webpage. - This allows for a better user experience on different device types and sizes by displaying the most appropriate image according to the device's resolution.
Syntax
The basic syntax of the HTML <picture>
tag is as follows:
<picture>
<source srcset="image1.jpg" media="(min-width: 1200px)">
<source srcset="image2.jpg" media="(min-width: 768px)">
<source srcset="image3.jpg">
<img src="default.jpg" alt="description of the image">
</picture>
Here, we define different sources for an image and their sizes by using the