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.
width = height × W ÷ H
| Ratio | Common use | At 800 px wide | At 360 px wide |
|---|---|---|---|
| 1:1 | Square thumbnails, profile images | 800 × 800 | 360 × 360 |
| 4:3 | Many camera photos, older screens | 800 × 600 | 360 × 270 |
| 3:2 | Many camera photos | 800 × 533.33 | 360 × 240 |
| 16:9 | Video, wide banners | 800 × 450 | 360 × 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
| Option | How it works | Cost |
|---|---|---|
| Reserved empty space | Width and height attributes only | Nothing extra |
| Solid color | A background color, often the image’s average color | One line of CSS |
| CSS gradient | Two or three colors sampled from the image | A few bytes |
| Tiny blurred preview | A very small version of the image, stretched and blurred | A 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
- Decide each image slot’s ratio first, from the content you expect.
- Create a box at that ratio in a neutral color.
- Label it with its dimensions and purpose, for example “1200 × 675, product photo”.
- 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.