Serve responsive images with srcset and sizes

With srcset and sizes, offer image widths that fit your layouts and let the browser choose for the displayed size and pixel density.

Serve images in next-gen formats such as WebP and AVIF

WebP and AVIF can compress better than PNG or JPEG. Serve them in a <picture> element, with a JPEG or PNG fallback for browsers that can't show them. Compare file sizes at the visual quality you need. Google's image performance guide explains responsive images and formats.

Why image elements need explicit width and height

Add width and height that describe the image's aspect ratio so the browser can reserve space before it loads. Keep responsive sizing in CSS. This avoids content moving to make room for the picture, as the layout shift guide explains.

Defer offscreen images without delaying your main image

Use loading="lazy" for pictures below the initial view. Leave it off the main image and other pictures visitors need as soon as the page opens. Browser lazy-loading guidance explains when to use it.

Frequently asked questions

What's the proper image size for a website?

There's no single size. Make each image as wide as the space it fills on screen, or twice that for screens with double pixel density, so a picture shown 500 pixels wide works best at about 1,000 pixels. Most people won't notice an image a little smaller than that.

  • Website speed

    Find what makes your pages slow enough that visitors leave.

  • Alt text

    Give useful images a text alternative and leave decorative images silent.

  • Page size

    Reduce download weight and page complexity by removing code and content you no longer need.