Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To create a website thumbnail background, first decide whether the image is decorative or whether it conveys information. Use CSS background-image for decoration behind a card or text; use an HTML <img> with useful alternative text when the image itself represents content. Choose a crop for the actual container, set a fallback color, and check the result at narrow widths. If you also need a social sharing preview, configure og:image separately: it does not set the page’s CSS background.

Choose the right kind of thumbnail

“Thumbnail background” can mean a visual background inside a website card, an informative thumbnail image, or the image shown when a page is shared. These uses may look similar, but their implementation and accessibility needs differ.

Use Best fit Important detail
Decorative card background CSS background-image Appropriate when the image adds atmosphere but is not essential information. Set a background color as a fallback.
Meaningful thumbnail content HTML <img> or <picture> Provide useful alternative text when the image conveys information. HTML image elements also support responsive sources and image discovery.
Social or page preview Open Graph metadata such as og:image This is metadata for preview surfaces, not a replacement for the image shown in the page layout.

CSS backgrounds are not exposed to assistive technology as image content, and Google says it does not index CSS images. Do not put essential information only in a CSS background, or rely on one when image discovery matters. MDN’s background-image reference and Google’s image guidance explain these distinctions.

Plan the size, crop, and focal point

There is no universal thumbnail pixel size that works for every website or preview surface. Start with the dimensions and aspect ratio of the card or placement you actually use, then choose an image with enough resolution for its display size. A source that looks good in an editor may crop badly when the browser fits it into a wide or tall container.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
  • Identify the container’s intended aspect ratio and likely rendered sizes.
  • Choose a representative image with a clear focal subject and useful space around it.
  • Decide which part of the image must remain visible when the container crops it.
  • Avoid forcing a source into a different ratio if doing so would stretch or squash it.
  • Test the crop on narrow and wide layouts, not just at one desktop size.

Google recommends representative, high-resolution preview images and advises against extreme aspect ratios, but does not prescribe one universal ratio. Preview-image selection is automated: supplying metadata can indicate a preferred image, but does not guarantee which image a search or sharing surface will show. See Google’s image guidance.

Create a decorative thumbnail background with CSS

Use a container with a deliberate ratio, a fallback color, and cover sizing when you want the image to fill the box. background-position controls which area stays in view as the image is cropped. Adjust it for the subject rather than assuming the center is always right.

<article class="thumbnail-card">
  <div class="thumbnail-card__content">
    <p>Field guide</p>
    <h2>A weekend on the coast</h2>
  </div>
</article>
.thumbnail-card {
  aspect-ratio: 16 / 9;
  min-height: 12rem;
  background-color: #243341;
  background-image: url("/images/coast-thumbnail.webp");
  background-size: cover;
  background-position: 50% 42%;
  color: white;
  display: flex;
  align-items: end;
}

.thumbnail-card__content {
  width: 100%;
  padding: 1.25rem;
  background: linear-gradient(transparent, rgb(0 0 0 / 75%));
}

@media (max-width: 40rem) {
  .thumbnail-card {
    aspect-ratio: 4 / 3;
    background-position: 62% center;
  }
}

The dark gradient is one way to improve text legibility, but check the actual image and text together: a gradient does not guarantee sufficient contrast everywhere. MDN notes that image-to-text contrast needs attention; its guidance gives WCAG thresholds of 4.5:1 for body text and 3:1 for large text. For detailed CSS behavior, consult MDN’s background-image reference.

What the CSS choices do

  • aspect-ratio reserves a predictable shape for the card. The mobile rule demonstrates that a different container ratio may suit a narrower layout.
  • background-color remains visible if the image is unavailable or still loading.
  • background-size: cover fills the box while preserving image proportions, which means some cropping is expected.
  • background-position moves the crop’s focal area. Values such as 62% center can keep a subject visible on a narrow card.

If the image is decorative, the CSS approach avoids adding an unnecessary image description to the content. If the image carries information, use an image element instead.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use an informative image when the thumbnail has meaning

For a content-bearing thumbnail, use semantic image markup and write alternative text that communicates the image’s relevant information in context. Do not describe decorative details that add nothing, and do not leave essential meaning available only in a background image.

<img
  src="/images/coast-thumbnail-960.webp"
  alt="Rocky coastline and a lighthouse above the sea"
  width="960"
  height="540"
  style="max-width: 100%; height: auto;"
>

The width and height describe the source image’s proportions, while max-width: 100% and height: auto let it fit a narrower space without overflowing or distorting. For responsive delivery, provide suitable variants with srcset and sizes, or use <picture> when you need to select among sources.

<img
  src="/images/coast-thumbnail-960.webp"
  srcset="/images/coast-thumbnail-480.webp 480w,
          /images/coast-thumbnail-960.webp 960w,
          /images/coast-thumbnail-1440.webp 1440w"
  sizes="(max-width: 40rem) 100vw, 50vw"
  alt="Rocky coastline and a lighthouse above the sea"
  width="960"
  height="540"
  style="max-width: 100%; height: auto;"
>

These example filenames and sizes are illustrative; choose variants that match your own assets and layout. Google recommends a fallback src and standard HTML image elements for image discovery. Its guidance does not establish a single required size for every thumbnail. See Google’s image guidance and the responsive sizing technique from the W3C.

Set a page-sharing thumbnail separately

When the goal is a social or other page preview, add Open Graph metadata to the page’s <head>. The og:image property identifies a preview image; optional properties can provide its dimensions and a text description. This does not change the thumbnail background rendered by your CSS.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<meta property="og:image" content="https://example.com/images/coast-share.jpg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Rocky coastline and a lighthouse above the sea">

Use a representative image and accurate metadata, but do not assume every platform will display it exactly as specified. Open Graph defines og:image and the optional image properties; consult the Open Graph protocol. Google also lists og:image as one way to indicate a preferred image while noting that its selection is automated: Google image guidance.

Check accessibility, responsiveness, and loading behavior

  • Alternative text: If the image communicates information, use an HTML image with an appropriate text alternative. A CSS background does not supply that alternative to assistive technology.
  • Text contrast: Check text against the actual crop at each layout size. Move the focal point or strengthen the overlay if needed; do not rely on a color treatment without checking the result.
  • Responsive fit: Verify the container’s crop at the narrowest layout you support and at larger sizes. For an image element, constrain its width and preserve its proportions to prevent overflow.
  • Fallback: Set a background color under CSS imagery. For an informative HTML image, keep a usable fallback src even when adding responsive variants.
  • Performance: Use image variants appropriate to their display size instead of delivering an unnecessarily large file to every viewport. The cited guidance supports responsive variants but does not prescribe a universally best format or compression setting.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common thumbnail problems

The subject is cut off

The container ratio and image composition do not match. For CSS backgrounds, adjust background-position, reconsider the card ratio, or select a source with more space around the subject. For a meaningful image, choose an asset composed for the intended crop rather than distorting it.

The background appears blank

Check that the image URL resolves from the page, that the CSS selector matches the element, and that a rule is not being overridden. Keep a fallback background-color so the card remains usable while you diagnose the image.

The thumbnail stretches or overflows

Do not force an image to dimensions that change its proportions. With an image element, use max-width: 100%; height: auto;, as in the W3C responsive sizing technique. For a background, cover preserves proportions but crops; if that crop is unacceptable, revise the aspect ratio or source image.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Text is hard to read over the image

Test contrast over the lightest and busiest parts of the crop. Change the focal point or add a suitable overlay behind the text. MDN identifies 4.5:1 for body text and 3:1 for large text as WCAG contrast thresholds in its discussion of image backgrounds: MDN.

The page preview shows another image

A CSS background is not the same as preview metadata. Add or correct og:image and its optional description and dimensions, then allow for the fact that preview-image selection is automated and can vary by surface. Neither Google’s guidance nor the Open Graph protocol promises that every consumer will display the specified image.

Or skip the browser setup

If you need a rendered screenshot of a page or preview, ScreenshotNeo can return a PNG, JPEG, WebP, or PDF through one GET request. Its API can remove cookie/consent banners, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, with the outcome reported in X-Page-Verdict and X-Billed headers. An MCP server provides screenshot tools for AI agents, and all features are on every plan.

For a WebP screenshot, replace the example URL with the page you want to capture:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for setup and parameters. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for free and get 1,000 screenshots a month with no card.

Frequently Asked Questions

Is a CSS background image accessible to screen readers?

Not as image content. Use an HTML image with appropriate alternative text when the image communicates information.

Does setting og:image create the thumbnail inside my website card?

No. It supplies page-preview metadata; use CSS or an HTML image element for the image rendered in the page layout.

Quick Recap

SaleBestseller No. 1
HTML and CSS: Design and Build Websites
HTML and CSS: Design and Build Websites
HTML CSS Design and Build Web Sites; Comes with secure packaging; It can be a gift option
$15.75
SaleBestseller No. 2
SaleBestseller No. 4

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.