Design comparison
SolutionDesign
Solution retrospective
How do I switch images from mobile to desktop?
Community feedback
- @khaya05Posted almost 2 years ago
Hi Abiala
To change images based on screen width/viewport you could use the HTML
<picture>
tag. The<picture>
tag contains two elements, one or more<source>
tags and one<img>
i.e
<picture> <source media="(min-width:48em)" srcset="tablet_img.jpg"> <source media="(min-width:75em)" srcset="desktop_img.jpg"> <img src="mobile_img.jpg" alt=""> </picture>
Checkout the mdn docs about the
<picture>
tag hereMarked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord