October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
accessibility

How to Use a Screenshot as a Website Background with CSS

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

Use CSS background-image to place a screenshot behind an element, then choose background-size: cover when the image should fill the box or contain when the complete screenshot must remain visible. Give the element a real height or content-driven size, set a fallback color, and adjust background-position to keep the important part in view.

Basic CSS: put the screenshot behind an element

A background image belongs to the element that should display it. The URL may point to a local asset or an image endpoint:

.hero {
  min-height: 24rem;
  background-color: #222;
  background-image: url("/images/screenshot.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

The selector, path and height are examples. Replace them with the element and asset used by your page. The element must have dimensions: a block with no content and no height can have no visible area for the background. Use a fixed or minimum height, padding, grid sizing, or other layout rules that create the required box.

Choose between cover and contain

Value What it does Use it when Trade-off
cover Scales the image proportionally until both dimensions cover the element. The region must be completely filled, such as a hero banner. Different aspect ratios crop part of the screenshot horizontally or vertically.
contain Scales the complete image proportionally inside the element. Every edge or detail of the screenshot must remain visible. Uncovered bands can appear; without no-repeat, the background may tile.
Explicit length or percentage Sets a particular background dimension; one value leaves the other dimension as auto. You have a deliberate sizing requirement. Two values can stretch the image, so use them only when distortion is acceptable.

These behaviors follow the CSS background sizing guidance in MDN’s background-size documentation. A screenshot and its container rarely share the same aspect ratio, so decide first whether filling the box or preserving the entire image matters more.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Control the crop with background-position

With cover, the browser must crop whichever dimension exceeds the element. The default center position keeps the middle visible:

.hero {
  background-position: center;
}

Move the focal area when the important content is near an edge:

.hero--product {
  background-position: 70% center;
}

.hero--header {
  background-position: center top;
}

Percentages describe the alignment of the image and container; keywords such as left, right, top and bottom are useful for predictable anchors. Check the result at each responsive breakpoint because a position that works on desktop can hide a subject on a narrow screen.

Build a readable, responsive hero

Place foreground content in the element rather than baking essential words into the screenshot. This keeps headings, links and controls available to search engines, keyboard users and assistive technology:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<section class="hero">
  <div class="hero__content">
    <p class="eyebrow">Product launch</p>
    <h1>A clear heading over the screenshot</h1>
    <a class="button" href="/learn-more">Learn more</a>
  </div>
</section>
.hero {
  min-height: clamp(20rem, 65vw, 42rem);
  display: grid;
  align-items: center;
  padding: 2rem;
  color: #fff;
  background-color: #222;
  background-image: url("/images/screenshot.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.hero__content {
  max-width: 42rem;
  padding: 1.25rem;
  background: rgb(0 0 0 / 0.45);
}

@media (max-width: 40rem) {
  .hero {
    background-position: 65% center;
    padding: 1rem;
  }
}

clamp() gives the section a usable minimum and maximum while allowing intermediate viewport sizes to adjust naturally. The translucent panel is one way to keep text legible; a gradient overlay or a different focal position may suit your image better.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Fallbacks and accessibility

Declare background-color before or alongside the image. If the image is unavailable, browsers treat it as absent and the color remains visible. Choose a color that still provides a usable page:

.hero {
  background-color: #20242a;
  background-image: url("/images/screenshot.png");
}

A CSS background is not announced as an image by screen readers. If the screenshot communicates information required to understand or use the page, repeat that information in semantic HTML. Do not put the only explanation of a chart, product state or instruction in the background.

Text over an image also needs sufficient contrast across the area where it appears. MDN reports the WCAG thresholds as 4.5:1 for normal body text and 3:1 for large text (at least 24px, or bold text around 18.66px). These are accessibility thresholds, not a contrast result for your particular screenshot. Test the actual image at its lightest and darkest regions, and add a solid or gradient layer when necessary.

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

Layer a screenshot with gradients or multiple backgrounds

CSS accepts a comma-separated list of backgrounds. The first layer is painted on top of later layers, so put an overlay gradient before the screenshot:

.hero {
  background-color: #1b1b1b;
  background-image:
    linear-gradient(90deg, rgb(0 0 0 / .72), rgb(0 0 0 / .12)),
    url("/images/screenshot.webp");
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

Each layer can have its own size, position and repeat value. Keep the fallback color because neither layer is guaranteed to load.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Use a screenshot as the whole page background

Apply the same properties to body or a page wrapper when the image should sit behind all content. A wrapper often makes stacking and readable content widths easier:

.page {
  min-height: 100vh;
  background-color: #242424;
  background-image: url("/images/site-shot.jpg");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.page__content {
  max-width: 70rem;
  margin-inline: auto;
  padding: 2rem 1rem;
}

For a fixed viewport effect, you can use background-attachment: fixed, but scrolling performance and mobile behavior vary. Treat it as an optional visual effect, not a requirement for the background to work.

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

Capture the screenshot you need

A local screenshot can be exported from your design or generated from a live page. Before using it, check its aspect ratio, file size, focal point and licensing. WebP or JPEG is usually smaller than PNG for photographic content; PNG is useful when sharp text or transparency matters. Resize oversized captures so the browser does not download pixels that the layout never displays.

Or skip the browser setup:

ScreenshotNeo is a website screenshot API and MCP server. One request returns a PNG, JPEG, WebP or PDF, so you can generate the asset in a script or build pipeline instead of manually opening a browser. Its capture can accept cookie and consent banners and remove more than 60 known consent platforms, newsletter popups and chat widgets before the shot; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and whether it was billed.

Here is a direct cURL request; see the ScreenshotNeo documentation for the complete option list:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

Useful options include full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets or a custom viewport, retina scale, custom CSS and JavaScript, clicks before capture, hidden selectors, waits for a selector, delay or network idle, blocked ads/trackers/requests/resource types, custom headers, cookies, user agent and Authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTL, signed links for public <img> tags, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to generate an asset for your CSS background.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting checklist

The background is invisible

  • Inspect the element and confirm it has height, padding or visible content.
  • Check the URL in the browser directly; a wrong relative path is the most common cause.
  • Look for a later background shorthand that resets background-image.
  • Confirm the image is not blocked by content-security-policy rules or mixed HTTP/HTTPS content.

The screenshot looks stretched

Use cover or contain instead of forcing two unrelated dimensions. If you set explicit width and height, preserve the source ratio or accept that distortion is intentional.

Important content is cut off

Switch from cover to contain if every edge must remain visible, or keep cover and move background-position toward the subject. Test narrow and wide layouts separately.

Empty bands or repeated tiles appear

contain can leave uncovered space. Set background-repeat: no-repeat, choose a compatible fallback color, and decide whether the bands are acceptable. If not, use cover or adjust the element ratio.

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

Text is hard to read

Measure contrast over the real image, then add a gradient, darker panel, text shadow used sparingly, or a different crop. Keep the WCAG thresholds in view rather than assuming one average color represents the whole screenshot.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

The API file is not a usable image

Check the HTTP status and response headers before saving. Authentication errors, rate limits and failed captures may return an error response rather than image bytes; handle non-2xx responses and review the X-Page-Verdict and X-Billed headers.

Practical decision guide

  • Choose cover for a filled hero where cropping is acceptable.
  • Choose contain for a reference image, mockup or screenshot whose complete content matters.
  • Use background-position to preserve the subject after responsive cropping.
  • Always provide a fallback color and a semantic equivalent for meaningful information.
  • Generate and optimize the image at the dimensions your layout actually needs.

Frequently Asked Questions

Can I use a screenshot in CSS without an HTML image element?

Yes. Set it with background-image on the target element. Use an HTML <img> instead when the image itself is meaningful content that should have alternative text.

Why does background-size: cover crop my screenshot?

It preserves the image ratio while covering both dimensions of the element. When the aspect ratios differ, excess image area must be cropped; change background-position or use contain.

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

What happens if the background image fails to load?

The browser displays the declared background-color fallback. Make that color usable and keep essential information in semantic HTML.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.