Prompt
What should I use if I need automatic image resizing by screen size?
Latest observation
Nov 3, 2026
OpenAI APIWeb search: off
If you want automatic image resizing based on screen size, the usual choice is:
Best option: Responsive images
Use HTML/CSS features that let the browser pick the right image size.
1) srcset + sizes
This is the most common and recommended approach for <img> tags.
<img
src="image-800.jpg"
srcset="image-400.jpg 400w, image-800.jpg 800w, image-1200.jpg 1200w"
sizes="(max-width: 600px) 100vw, 50vw"
alt="Example">
srcsetgives multiple image sizessizestells the browser how big the image will display at different screen widths- The browser automatically chooses the best file
2) CSS max-width: 100%
If you just want the image to scale down within its container:
img {
max-width: 100%;
height: auto;
}
This makes the image responsive, but it does not choose different file sizes automatically.
3) Use <picture> for art direction
If you want different crops or entirely different images for different screen sizes:
<picture>
<source media="(max-width: 600px)" srcset="small.jpg">
<source media="(max-width: 1200px)" srcset="medium.jpg">
<img src="large.jpg" alt="Example">
</picture>
If you want a framework/library
- React/Next.js:
next/image - Cloudinary, Imgix, ImageKit: automatic resizing/CDN-based optimization
- Bootstrap/Tailwind: good for layout responsiveness, but not automatic image file selection by themselves
Short recommendation
- For plain HTML: use
srcset+sizes - For container scaling only: use CSS
max-width: 100% - For different images per breakpoint: use
<picture>
If you want, I can show you the best setup for React, plain HTML, or CSS background images.