Blog · Design tools

How to use placeholder images in HTML and CSS

The most reliable placeholder is one you own: a small SVG saved in your project or pasted as a data URI, with width and height set so the layout does not move when the real image arrives. No third-party service, no broken images.

Title card reading “Placeholder images in HTML and CSS” beside a screenshot of the Digital Sauce placeholder image generator previewing a grey placeholder labelled 1200 × 630.

Here are the four patterns we use when building sites before the photos are ready. Each one works offline and keeps your layout honest. Make the images with our free placeholder image generator, which can copy a file, data URI or <img> tag.

1. A local file

<img src="/img/placeholder-1200x630.svg" width="1200" height="630" alt="Hero image coming soon">

Download an SVG or PNG and commit it next to your other images. It is the most boring option and the most robust. The width and height attributes let the browser reserve the right space before the image loads, which prevents layout shift (web.dev: Optimize CLS).

2. An inline data URI

<img src="data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='400'%3E…%3C/svg%3E" width="600" height="400" alt="">

A data URI puts the image inside the HTML, so there is no extra request. SVG placeholders are a few hundred bytes, which makes this practical. The generator's Copy <img> tag button gives you exactly this. Keep large PNG data URIs out of HTML, as they bloat every page load. MDN explains the format in data: URLs.

3. A CSS box (no image at all)

.ph { aspect-ratio: 16 / 9; background: #e9e9e9; border-radius: 16px;
      display: grid; place-items: center; color: #5f5f5f; font: 600 14px system-ui; }
<div class="ph">Product video, 16:9</div>

Sometimes you do not need an image file at all. A styled box with aspect-ratio holds the space and describes what goes there. See CSS aspect-ratio for more patterns.

4. A CSS background

.hero { background: #e9e9e9 url("data:image/svg+xml;charset=utf-8,…") center / cover no-repeat; }

Useful for hero areas that will later get a background photo. Paste the generator's data URI into url(), inside quotes.

Placeholders in Figma and other design tools

Download a PNG at the size of your frame and drag it in, or use it as an image fill so you can swap the real image in later without resizing anything. Label placeholders with what they are ("Founder portrait, 4:5"), not just the size, so reviewers know what is missing.

What to avoid

  • Hosted placeholder URLs in production. They depend on someone else's server. Compare options in the best free placeholder image generators.
  • Missing alt text. If the placeholder is decorative, use alt=""; if it stands in for meaningful content, describe what will be there.
  • Shipping placeholders by accident. Give the files an obvious name such as placeholder- so a search before launch finds them.

Placeholder image generatorMake placeholder images at any size, as PNG, JPG, WebP or SVG. Free, no sign-up, runs in your browser.

Open the tool →

FAQ

How do I add a placeholder image in HTML?

Use an img tag pointing to a local placeholder file or an SVG data URI, and include width, height and alt attributes. The Digital Sauce generator can copy the whole tag for you.

What is a data URI image?

It is an image written directly inside a URL, starting with data:image/. The browser decodes it without making a separate request, which suits tiny images like SVG placeholders.

How do I make a placeholder in CSS without an image?

Style an empty box with a background colour and aspect-ratio, for example aspect-ratio: 16 / 9, and put a short label inside it.

Do placeholder images hurt page speed?

Small SVG placeholders barely register. Large PNG data URIs or hosted placeholders on a slow server can, so keep them small and local.

Should placeholder images have alt text?

Yes. Use an empty alt for purely decorative placeholders, or a short description of the content that will replace it.

Last updated 16 November 2026. Sources are linked in the text. Spotted something out of date? Email development@digitalsauce.io.

Need a design system that ships?

Digital Sauce designs and builds apps and websites in Melbourne, from brand colours to the code.

Start a project →