SpunkArt
Color, art and images

How to use placeholder images and reserve image space

A placeholder stands in for an image that is not ready yet, either while you design a page or while a real photo loads. Done well, it keeps the layout steady and the page quick.

Two different jobs

The word “placeholder” covers two situations, and they need different solutions.

  • Design placeholders are grey or labelled boxes in a mock-up, used before the real photos exist. They should have the final size and shape so the layout is honest.
  • Loading placeholders are what visitors see for a moment while the real image downloads: a block of color, a blurred preview or simply reserved empty space.

Aspect ratio maths

An aspect ratio is width divided by height, written as W:H. If you know the ratio and one side, you can find the other.

height = width × H ÷ W
width = height × W ÷ H
RatioCommon useAt 800 px wideAt 360 px wide
1:1Square thumbnails, profile images800 × 800360 × 360
4:3Many camera photos, older screens800 × 600360 × 270
3:2Many camera photos800 × 533.33360 × 240
16:9Video, wide banners800 × 450360 × 202.5

Worked example. A 16:9 hero image will fill a column 800 pixels wide. Height = 800 × 9 ÷ 16 = 450 pixels. On a phone column 360 pixels wide, the same image is 360 × 9 ÷ 16 = 202.5 pixels tall, which the browser rounds when it draws.

Reserve the space to stop layout shift

If the browser does not know an image’s shape, it gives it zero height until the file arrives. Then everything below jumps down. This jump is called layout shift, and it is one of the page-experience measures in Google’s Core Web Vitals.

The simplest fix is to put the real width and height on every image tag. Modern browsers use the two numbers to work out the aspect ratio and reserve the right space, even when CSS makes the image responsive:

<img src="/art/cosmos.jpg" width="1200" height="900" alt="...">
img { max-width: 100%; height: auto; }

For boxes that are not images, such as an embedded video, use the CSS aspect-ratio property: aspect-ratio: 16 / 9;.

Loading placeholder options

OptionHow it worksCost
Reserved empty spaceWidth and height attributes onlyNothing extra
Solid colorA background color, often the image’s average colorOne line of CSS
CSS gradientTwo or three colors sampled from the imageA few bytes
Tiny blurred previewA very small version of the image, stretched and blurredA small extra file or inline data

For most sites, reserved space plus a background color is enough. The blurred preview looks smooth but adds work to your build process.

Making design placeholders by hand

  1. Decide each image slot’s ratio first, from the content you expect.
  2. Create a box at that ratio in a neutral color.
  3. Label it with its dimensions and purpose, for example “1200 × 675, product photo”.
  4. Use the same ratios in the final design, so swapping in real images changes nothing else.

An inline SVG with a rect and a text element makes a good labelled placeholder that needs no file. The SVG guide shows the syntax.

Common mistakes

  • Shipping placeholders. Search the finished site for “placeholder” and any sample image names before launch.
  • Stock photos of the wrong shape. Crop the real photos to the slot’s ratio, or they will be cropped unpredictably by CSS.
  • Lazy-loading the first image. Images visible as soon as the page opens should load straight away. Use loading="lazy" on images further down.

Questions people ask

Do I still need width and height if CSS sets the size?

Yes. The browser uses them for the ratio before CSS and the image file are ready. Use the image file’s real pixel size.

Should placeholder text say “Lorem ipsum”?

For layout, that is fine. For images, a label with the size and purpose is more useful to whoever supplies the final photos.