← All articles

Performance

Images for the web

Choose formats, dimensions and alternative text.

On this page

  1. Choose the appropriate format
  2. Provide suitable dimensions
  3. Describe the purpose

Choose the appropriate format

SVG works well for diagrams and icons; WebP or AVIF can reduce photographic image sizes. PNG remains useful for lossless graphics.

Provide suitable dimensions

Width and height attributes allow browsers to reserve layout space. Use responsive source sets when different viewport sizes need different image resolutions.

Describe the purpose

Informative images need meaningful alternative text. Decorative images should use an empty alt attribute so assistive technology can skip them.

Example

<img src="diagram.svg" width="640" height="360"
     alt="Three steps in the publishing workflow">

Related reading