Placeholder Images, Aspect Ratios and Layout Shift (CLS): A Practical Guide
Placeholders do two jobs in web design. During design and development, they stand in for images that don’t exist yet. On live sites, they hold space for images that are still loading, so the page doesn’t jump. Both matter: one keeps projects moving, the other directly affects user experience and Google’s Core Web Vitals.
Placeholders in design and prototyping
Real photography often arrives late. Placeholder images let you build and review layouts without waiting. Good placeholders:
- use the correct dimensions and aspect ratio, so the layout you approve is the layout you’ll ship,
- are labelled with their purpose and size, like “Team photo 4:5 – 1200 × 1500”, so whoever supplies the final images knows what to deliver,
- are neutral in color, so they don’t influence feedback on the color scheme.
Online placeholder services that generate images from a URL are convenient, but they make your mockups depend on a third party staying online. Generating placeholders locally avoids that. The placeholder image generator above creates PNG, JPG, WebP or tiny SVG files at any size, offline.
Layout shift: the real problem placeholders solve
When a browser loads a page, it starts laying out text before images have downloaded. If it doesn’t know how big an image will be, it reserves no space. When the image arrives, everything below it gets pushed down. You’ve probably experienced the result: you go to tap a link, an image loads above it, and you tap an ad instead.
Google measures this as Cumulative Layout Shift (CLS), one of the three Core Web Vitals.
| CLS score | Rating |
|---|---|
| 0.1 or less | Good |
| 0.1 – 0.25 | Needs improvement |
| Over 0.25 | Poor |
The score combines how much of the viewport moved and how far. Images and embeds without reserved space are the most common cause.
Fix 1: width and height attributes
The simplest fix is to include width and height on every <img>:
<img src="photo.webp" width="1200" height="800" alt="…" style="width:100%;height:auto">Modern browsers (since around 2020) use these attributes to calculate the aspect ratio before the image loads, even when CSS makes the image responsive with width: 100%; height: auto. The browser reserves a box of the right proportions, and the image fills it.
Fix 2: CSS aspect-ratio
For containers, background images, videos and embeds, use the aspect-ratio property:
.video { aspect-ratio: 16 / 9; width: 100%; }
.avatar { aspect-ratio: 1; }Supported in all major browsers since 2021, it replaced the old “padding-top: 56.25%” hack for 16:9 boxes. If you need to work out a ratio, our aspect ratio calculator simplifies any dimensions.
Loading placeholders: what to show while waiting
Reserving space prevents shifting, but an empty box can still look broken. Several techniques fill the gap:
| Technique | What users see | Extra cost | Notes |
|---|---|---|---|
| Solid neutral color | A grey or beige box | None | Simplest; fine for small images |
| Dominant color | A box in the image’s main color | A few bytes | Feels connected to the image |
| LQIP (low-quality image placeholder) | A tiny blurred version, scaled up | ~0.5–2 KB inlined | Smooth “blur-up” when the full image loads |
| BlurHash / ThumbHash | A short string decoded into a blurred preview | ~20–30 characters | Popular in apps and APIs |
| SVG trace / silhouette | A simplified outline | 1–3 KB | Artistic; less common now |
| Skeleton screen | Grey shapes for the whole layout | Minimal | Good for cards and feeds |
Dominant color is a nice balance: extract it once with an image palette extractor and set it as the background color of the image container. For skeletons and spinners, see our loading states guide.
Lazy loading and placeholders
loading="lazy" tells the browser to load off-screen images only as the user scrolls near them. It saves bandwidth, but it makes reserved space even more important, because more images load after the page is visible. Two rules:
- Always include dimensions on lazy-loaded images.
- Don’t lazy-load the main image at the top of the page (often the Largest Contentful Paint element); load it immediately, and consider
fetchpriority="high".
Other common causes of layout shift
- Web fonts that swap in with different metrics. Use
font-display: swapwith a well-matched fallback, or size-adjust descriptors. - Ads and embeds without reserved space. Give their containers a min-height.
- Banners injected at the top of the page after load (cookie notices, promos). Overlay them or reserve their space.
- Dynamic content inserted above what the user is reading.
Placeholder checklist for developers
- Every image has width and height attributes or a container with
aspect-ratio. - Hero images load eagerly; everything below the fold loads lazily.
- Containers have a background color matching the image’s tone.
- Mockup placeholders match final dimensions and are labelled.
- Search the codebase for placeholder URLs before launch.