$html-docs
InstallDevelopersPricingSign inOpen drive
All HTML guides
Performance8 min read·July 29, 2026

How to Serve Responsive Images in HTML

Use width, height, srcset, sizes, picture, and loading hints to deliver sharp images without wasting bandwidth.

The short version

Give the browser enough information to choose the right image before layout begins.

01

Reserve space and describe the image

Set intrinsic width and height so the browser can calculate the aspect ratio before the file arrives. This reduces layout movement. Write alt text that communicates the image purpose; use an empty alt value when the image is purely decorative.

html
<img
  src="/report-960.webp"
  srcset="/report-480.webp 480w,
          /report-960.webp 960w,
          /report-1440.webp 1440w"
  sizes="(max-width: 720px) 100vw, 720px"
  width="1440"
  height="900"
  alt="HTML report with inline comments beside a revenue chart"
>
02

Use picture for art direction

Use srcset when the same image can be served at different resolutions. Use picture when the composition itself should change, such as a wide desktop screenshot becoming a tighter mobile crop.

Do not lazy-load the primary image in the first viewport. Images farther down the page are good candidates for loading="lazy".

03

Measure the actual transfer

Open the page on a narrow viewport with network throttling. Confirm the selected resource is close to the rendered size, modern formats are compressed appropriately, and the image does not delay the main content.

  • Keep text as HTML rather than baking it into an image.
  • Use decoding="async" for non-critical images when appropriate.
  • Compress from the source asset, not a previously compressed export.
  • Provide a stable fallback src.

Official references

  • WHATWG: Images
  • web.dev: Responsive images

In this guide

  1. 01Reserve space and describe the image
  2. 02Use picture for art direction
  3. 03Measure the actual transfer
Publish a page

Keep going

Related HTML guides

Browse all 24 guides
Performance8 min read

A Practical HTML Performance Checklist

Reduce render-blocking work, prioritize the first viewport, and ship a smaller page before reaching for complex tooling.

Read guide
Foundations7 min read

How to Write Semantic HTML That Stays Useful

Choose elements for their meaning, build a clear document outline, and make your page easier to navigate, edit, and reuse.

Read guide
Accessibility8 min read

How to Build Accessible HTML Forms

Connect every field to a label, group related controls, explain errors clearly, and make the full flow work from a keyboard.

Read guide
© 2026 HTML DocsInstallSupportPrivacyTermsAPI