HTML Tutorial
<picture>
The <picture>
tag allows you to specify multiple image sources for a responsive web design. It ensures that the most appropriate image is loaded based on various factors such as device type, screen size, and pixel density.
<picture>
srcset
attribute.<picture>
<picture>
<source srcset="large.jpg 800w, medium.jpg 600w, small.jpg 400w" type="image/jpeg" media="(min-width: 1024px)">
<source srcset="medium.jpg 600w, small.jpg 400w" type="image/jpeg" media="(min-width: 768px)">
<img src="small.jpg" alt="Image">
</picture>
In this example:
media
attribute specifies the screen size where each source should be used.Exploring the <picture>
tag
To experiment with the <picture>
tag, visit the following resources: