Responsive Images
Learn how to make images adapt to any screen size without wasting bandwidth or breaking layouts.
Why images need special treatment
By default, an image displays at its natural pixel dimensions. A 2000px-wide photo will be 2000px wide on screen — blowing past the edges of a phone screen and creating a horizontal scrollbar. Unlike text, which naturally wraps to fit its container, images are rigid rectangles. They don't reflow.
But the problem goes deeper than layout. A 2000px-wide image might be 500KB or more. On a phone screen that's only 375px wide, most of those pixels are wasted — the browser downloads a huge file and then shrinks it down visually. The user waits for a massive download they can't even see at full resolution. On slow mobile connections (3G, spotty Wi-Fi), this can mean several seconds of loading time for a single image. Instagram solves this by serving different image sizes for different screens: a small image for phone thumbnails, a medium image for the feed, and the full resolution only when you zoom in. Responsive images give you the same power — serve the right image for the right screen.