Prompt
How do I make responsive images for mobile, tablet, and desktop?
Latest observation
Nov 3, 2026
OpenAI APIWeb search: off
To make responsive images for mobile, tablet, and desktop, you usually want the browser to load the most appropriate image size for the user’s screen.
1) Use srcset and sizes for different screen widths
This is the most common and recommended approach.
<img
src="image-800.jpg"
srcset="
image-400.jpg 400w,
image-800.jpg 800w,
image-1200.jpg 1200w
"
sizes="
(max-width: 600px) 100vw,
(max-width: 1024px) 50vw,
800px
"
alt="Example image"
/>
How it works
srcsetgives the browser multiple image file options.sizestells the browser how wide the image will be displayed at different viewport widths.- The browser picks the best file automatically.
2) Use the <picture> element for art direction
If you want to show completely different crops or compositions on mobile vs desktop, use <picture>.
<picture>
<source media="(max-width: 600px)" srcset="mobile.jpg">
<source media="(max-width: 1024px)" srcset="tablet.jpg">
<img src="desktop.jpg" alt="Example image">
</picture>
Use this when:
- Mobile needs a different crop
- Desktop needs a wider version
- You want different images, not just different sizes
3) Make images scale with CSS
For fluid layouts, make sure images don’t overflow their containers:
img {
max-width: 100%;
height: auto;
}
This keeps the image responsive inside its parent container.
4) Consider modern formats
Use newer formats for better compression:
- WebP
- AVIF
You can provide fallback formats too:
<picture>
<source srcset="image.avif" type="image/avif">
<source srcset="image.webp" type="image/webp">
<img src="image.jpg" alt="Example image">
</picture>
5) Good practice
- Export multiple sizes from your design tool
- Use appropriately compressed images
- Match image dimensions to real display needs
- Add
widthandheightattributes to reduce layout shift
<img src="image-800.jpg" width="800" height="600" alt="Example">
Quick recommendation
- Use
srcset+sizesfor most responsive images - Use
picturewhen the image itself should change between breakpoints - Always use CSS to make images scale
If you want, I can give you:
- a plain HTML/CSS example,
- a React/Next.js example, or
- a complete responsive image setup for mobile/tablet/desktop.