Skip to content
BENIBIX Learn

Responsive Images

Design🌐 Web DesignResponsive Layout

Also known as Responsive Image, srcset, Picture Element, Adaptive Images

Each screen gets an image of the right size. Phones load small files.

Think of it like

A café pours a small cup for a small kid. A big person gets a big cup.

Example

Emma's hero photo comes in 480, 960 and 1920 pixel widths. Phones load the small one and save over a megabyte.

Why it matters

Images are often the heaviest part of a page. Sending the right size makes pages load much faster on phones.

Definition

Responsive images send each screen a picture of the right size. The page lists a few sizes of the same image. The browser picks the smallest one that still looks sharp on that screen. A phone downloads a small file and a big screen gets a large one. The picture element can also swap in a different crop for small screens.

Example code

html
<img src="cake-960.jpg"
  srcset="cake-480.jpg 480w, cake-960.jpg 960w, cake-1920.jpg 1920w"
  sizes="(max-width: 600px) 100vw, 50vw"
  alt="A slice of lemon cake on a white plate">
Three sizes of one photo. The browser picks the smallest that still looks sharp.
Each of these layouts can load its own size of the same photo.

Common mistake

Shrinking a huge image with code. The phone still downloads the whole big file.

Key takeaways

  1. 1
    Several sizes. Of the same picture.
  2. 2
    Browser chooses. Smallest that looks sharp.
  3. 3
    Crop for small. A tighter shot on phones.