1. Presentation
  2. Images

Presentation ยท Layer 2

Images

Images carry much of a page's meaning and most of its bytes. Using them well means choosing them, sizing them, describing them and delivering them with care, for every reader on every connection. These pages teach that care one topic at a time.

How these pages use images

Every example in this section follows the same rules, and the pages explain why as they go:

The CSS in these pages follows the CSS section's house style. Every byte count quoted comes from a real file, encoded by the site's own build script.

The pages

  1. 01What an image costs

    Why images dominate page weight, the question to ask first, raster and vector, pixel math, CSS pixels and device pixels, and content versus presentational images.

  2. 02Raster formats

    Lossless and lossy compression; GIF, JPEG, PNG, WebP, AVIF and JPEG XL; transparency, animation, and a format decision tree.

  3. 03SVG and vector images

    SVG as markup, three ways to put it on a page, styling it with currentColor, accessible SVG, icon systems, and optimization.

  4. 04Images in HTML

    The parts of <img>, <figure>, srcset and sizes, and <picture> for formats, crops and color schemes.

  5. 05Images in CSS

    Backgrounds, gradients, image-set(), list markers, masks and borders, object-fit, and when an image belongs in CSS at all.

  6. 06Fluid and responsive images

    The fluid baseline, reserving space against layout shift, resolution switching and art direction, and a worked sizes example.

  7. 07Images for people

    Alt text that does its job, images that fail, users' settings, and images across languages and cultures.

  8. 08Image performance

    Less data, less often, when needed, from nearby: optimizing, loading, preloading, caching, CDNs, and measuring the result.

Films

Three narrated films go with these pages.