I believe in srcset for sure. First it is more semantic than a simpler img tag, you can use <figcaption>
etc.
After the test I made, it loads only the image for the right resolution.
Withthisyoucanmaintainahigherqualityintheimagesandnotonlyusea"stretched" image for any resolution, changing only width
and height
in @ , here you really use a different image in a practical way!
You can use srcset
in this way for example:
<figure>
<picture>
<source media="(min-width: 2000px)" srcset="suaimagem-grande.png" sizes="100vw"/>
<source media="(min-width: 1500px)" srcset="suaimagem-pequena.png" sizes="100vw"/>
<figure>
<picture>
Here is a practical example and note that when you display the Snippet in "Full screen" the image will change.
.item {
background: url(http://placecage.com/600/200) no-repeat;
background-size: cover;
padding: 10px;
position: relative;
display: flex;
}
picture {
margin: auto
}
<figure class="item">
<picture>
<source srcset="https://cdn4.iconfinder.com/data/icons/icocentre-free-icons/114/f-cross_256-128.png" media="(min-width:768px)" />
<source srcset="https://cdn4.iconfinder.com/data/icons/icocentre-free-icons/137/f-check_256-128.png" media="(min-width:450px)" />
<img src="http://placecage.com/300/300"alt="imagem de fundo do banner" />
</picture>
</figure>
Here is a practical example. link
I recommend reading this response Mobile First: Appear image only on the desktop
And from the W3C Git documentation: link