October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober 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 Add Screenshots in HTML Code: Embed, Optimize, and Capture Images

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

To add an existing screenshot to an HTML page, save the image where your site can serve it and reference it with an <img> element. A useful minimum is:

<img src="images/homepage-screenshot.png" alt="Homepage showing the site navigation and featured article">

HTML displays an image resource; it does not take a picture of the browser window. If you need an automatic capture, use browser automation such as Playwright or a capture service, then embed the resulting file.

Display an existing screenshot with <img>

Put the screenshot in your project (for example, an images/ directory) or make it available at a URL that your visitors can reach. The value of src is resolved relative to the HTML document when you use a relative path.

<figure>
  <img src="images/settings-screen.png"
       alt="Settings page with the notification toggle enabled"
       width="1280" height="800">
  <figcaption>The notification setting is enabled in account settings.</figcaption>
</figure>

Choose the right path

  • Relative path: images/homepage.png works when the file is deployed in an images folder relative to the page.
  • Root-relative path: /images/homepage.png starts at the website root and is useful when many pages share one asset directory.
  • Absolute URL: https://example.com/images/homepage.png loads from another host, provided that host permits access and remains available.

Check spelling and letter case: a path that works on a case-insensitive computer can fail on a case-sensitive web server. Also verify that the image was included in your deployment rather than left only on your local machine.

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.
#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

Write useful alternative text

alt is the text fallback when an image cannot be processed and is read by assistive technology. Describe the information a reader would otherwise miss, not merely “screenshot.” For example, alt="Checkout page showing a total of $49 and the Pay button" conveys the relevant content. If the image is purely decorative and adds no information, use alt="". A visible caption adds context but does not replace suitable alternative text.

Reserve space with dimensions

When the intrinsic dimensions are known, include matching width and height attributes. The browser can reserve the correct aspect ratio before the file finishes loading, reducing layout movement. CSS can still make the image responsive:

.screenshot {
  max-width: 100%;
  height: auto;
  display: block;
}
<img class="screenshot"
     src="images/homepage-screenshot.png"
     alt="Homepage showing the site navigation and featured article"
     width="1440" height="900">

Do not invent dimensions. If you do not know the intrinsic size, omit the attributes until you can measure the file.

Make screenshots responsive

A single large screenshot may be unnecessarily heavy on a phone, while a small image becomes blurry on a wide display. Use srcset with width descriptors and sizes to describe the rendered width:

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.
<img src="images/dashboard-800.png"
     srcset="images/dashboard-400.png 400w,
             images/dashboard-800.png 800w,
             images/dashboard-1600.png 1600w"
     sizes="(max-width: 600px) 100vw, 800px"
     alt="Dashboard screenshot showing monthly activity"
     width="1600" height="1000">

The browser chooses a candidate using the viewport, display size, and device pixel ratio. The width descriptors must match the actual pixel widths of the files. Keep the same subject and crop across variants when you want ordinary resolution switching.

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

Use <picture> for art direction or formats

Use <picture> when mobile needs a different crop, or when you provide alternate formats. Each <source> has a condition; the fallback <img> remains required:

<picture>
  <source media="(max-width: 600px)" srcset="images/dashboard-mobile.webp">
  <source type="image/avif" srcset="images/dashboard.avif">
  <img src="images/dashboard.png"
       alt="Dashboard screenshot showing monthly activity"
       width="1600" height="1000">
</picture>

Keep the alternative text on the fallback image. It applies regardless of which source is selected.

Embed a screenshot from a hosted URL safely

If another service hosts the image, use its stable, direct image URL rather than a page URL that merely displays the image. Confirm that the host allows hotlinking, uses HTTPS, and will not require a login for your visitors. For private or expiring assets, serve the image through your own application instead of exposing a credential in HTML.

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

Do not put API keys, cookies, or authorization headers in an src attribute. Those values become visible to every visitor and may be copied.

When you actually need to create the screenshot

There are three different jobs:

Goal Appropriate workflow Important consideration
Show a file you already have <img> with src Correct path, meaningful alt, and dimensions
Produce repeatable captures in tests or a build Playwright page, full-page, or element screenshot Choose viewport, page extent, and target element
Let a user select live browser content Browser Screen Capture APIs User permission and browser/API support are required

Capture screenshots with Playwright

Playwright can save the visible viewport, the complete scrollable page, or one element. Install it in your project, then use a script such as:

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.
import { chromium } from 'playwright';

const browser = await chromium.launch();
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.screenshot({ path: 'homepage.png', fullPage: true });
await browser.close();

For one component, locate it and capture only that region:

const card = page.locator('[data-testid="pricing-card"]');
await card.screenshot({ path: 'pricing-card.png' });

After the script runs, copy the generated file into your website’s asset directory and reference it with <img>. In production, wait for the content that matters (for example, a chart or a specific selector), use a deterministic viewport, and avoid capturing while animations are changing the layout.

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

Capture live browser content with Screen Capture APIs

A web application can ask a user to select a tab, window, or screen through browser Screen Capture APIs and process the returned media track. This is an interactive permission-based workflow, not a replacement for a static image element. Browser support, secure-context requirements, and the user’s permission affect whether it works. If your goal is a server-side or unattended screenshot, browser automation or an API is usually a better fit.

Or skip the browser setup: ScreenshotNeo

ScreenshotNeo returns a PNG, JPEG, WebP, or PDF from one GET request, so you can generate an image without installing a browser. Before capture it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and whether the request was billed.

Use the ScreenshotNeo documentation for authentication and all options. This basic cURL request writes a WebP file:

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(`HTTP ${res.status}`);
const buffer = Buffer.from(await res.arrayBuffer());
await Bun.write('shot.webp', buffer);

ScreenshotNeo also offers full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper and page-range controls, HTML/CSS-to-image, custom JavaScript and CSS, clicks before capture, selector waits or delays, network-idle waits, ad/tracker/request blocking, custom headers, cookies, user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs also work for easier migration. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

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
Plan Included shots Price
Free 1,000 per month $0, no card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Every feature is on every plan, and yearly billing gives two months free. After saving the returned file, embed it normally:

<img src="shot.webp" alt="Stripe homepage captured for documentation" width="1440" height="900">

Sign up for ScreenshotNeo to get 1,000 screenshots a month free with no card; paid plans start at $5 for 3,000.

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

Troubleshoot broken or poor screenshots

“The image icon is broken”

  • Open the exact src URL directly in a browser.
  • Check relative path calculation from the HTML file, spelling, and capitalization.
  • Confirm the image was uploaded and the server returns an image content type rather than an HTML error page.
  • Inspect the browser’s Network panel for a 404, 403, redirect, or mixed-content error.

The image is stretched or causes layout jumping

Use the file’s real aspect ratio in width and height, then apply max-width:100%; height:auto. Do not set unrelated width and height values that distort the screenshot.

The screenshot is blurry

Provide a larger source or a correctly populated srcset. Ensure width descriptors match real file widths and that CSS is not displaying a small image far beyond its native dimensions.

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

Playwright captures a blank or incomplete page

Wait for the application’s actual readiness signal instead of assuming navigation finished. Try a selector wait, allow images and fonts to load, disable transitions, and capture after the data request completes. For pages that require login, supply credentials securely to the automation environment rather than writing them into the page URL.

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.

A Screen Capture request is denied

Explain the permission prompt and run from a secure context where required. The user must actively choose the content; a script cannot silently capture another tab or screen.

Production checklist

  • The image is deployed at the exact path used by src.
  • The alt text communicates meaningful content, or is empty for decoration.
  • Intrinsic dimensions are present when known.
  • Responsive variants use valid srcset and sizes descriptors.
  • CSS preserves the aspect ratio and limits width on narrow screens.
  • Private assets do not expose keys, cookies, or authorization data.
  • Automated captures wait for the page state you actually need.
  • Captures are checked at the target viewport and after deployment.

Frequently Asked Questions

Can I put a screenshot directly inside an HTML file without a separate image request?

Yes. Convert the image to a data URL and use it as the src value, but this increases HTML size and can make caching less efficient. A normal image file is usually easier to maintain.

Should a screenshot be PNG, JPEG, or WebP?

Choose based on the image and your delivery requirements: PNG preserves sharp UI text and transparency, while JPEG and WebP can reduce file size. Test readability after compression.

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

How do I prevent a screenshot from being indexed as page content?

Use appropriate robots and server policies for the asset or host it where it is not publicly discoverable. The alt attribute should still describe meaningful content for accessibility.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver 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.