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
Canvas API

How to Fix Gray or Grayscale Borders in html2canvas Exports

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

A gray, soft, or unexpectedly dark border in an html2canvas image usually has one of two causes: the border is being rasterized between output pixels, or html2canvas is reconstructing a CSS combination it does not fully support. Check the exported bitmap at its native size, verify pixel alignment and scaling, then isolate the CSS that triggers the artifact. No single rule—including imageSmoothing: false—fixes every case.

What the gray border means

html2canvas does not copy the browser’s already-rendered pixels. It reads the DOM and CSS, then builds a new canvas image from the properties it understands. That distinction explains why a page can look correct in Chrome or Edge while its export has a grayscale edge. The browser and html2canvas may rasterize the same geometry differently, and html2canvas’s CSS support is necessarily incomplete: every CSS property needs its own rendering implementation.

Canvas antialiasing is the other major explanation. If a border edge lands between device pixels, the renderer blends neighboring pixels so the edge appears gray rather than the default black or the exact border color. Fractional element coordinates, fractional widths, transforms, device-pixel-ratio scaling, and a later resize can all create that situation.

Diagnose the export before changing CSS

  1. Inspect the bitmap at 100%. Open the downloaded PNG in an image editor or an image element whose CSS width and height equal the file’s intrinsic dimensions. A border that looks gray only after you enlarge or shrink the image may be a display-scaling artifact, not an html2canvas rendering error.
  2. Record the dimensions. Log the canvas width and height, the element’s bounding rectangle, the configured scale, and the displayed image dimensions. Compare the bitmap’s pixel dimensions with the CSS dimensions used on the page.
  3. Check the effective scale. html2canvas documents window.devicePixelRatio as the default for scale. A fractional device-pixel ratio can map an otherwise whole CSS-pixel edge onto a fractional output coordinate. Test an explicit integer scale, such as scale: 1 or scale: 2, while keeping the element dimensions unchanged.
  4. Reduce the case. Copy the element into a minimal page and remove visual effects one at a time. Start with box-shadow, border-radius, transforms, filters, pseudo-elements, and nested clipping. Restore each declaration individually.
Observation Most useful test What the result tells you
Gray line changes when the image is resized in CSS Compare the native bitmap at 100% The later interpolation step is involved
Line changes when scale changes Try explicit integer scales Pixel-grid alignment is likely involved
Line remains in a minimal reproduction Remove radius, shadow, transforms and filters separately A specific CSS feature or interaction may be unsupported or incorrectly reconstructed
Line disappears when one declaration is removed Use an export-only override That declaration is the practical trigger for this export

Fix fractional geometry and scaling

Use integer-aligned dimensions where practical

Inspect getBoundingClientRect() for fractional x, y, width, or height values. Layouts based on percentages, flex distribution, transforms, or odd viewport widths commonly produce decimals. If the design allows it, set the exported component’s width, height, position, and border width so their effective output coordinates are whole pixels.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Dell Optiplex 7050 SFF Desktop PC Intel i7-7700 4-Cores 3.60GHz 32GB DDR4 1TB SSD WiFi BT HDMI Duel Monitor Support Windows 11 Pro Excellent Condition(Renewed)
  • Model: Dell OptiPlex 7050 Small Form Factor (SFF)
  • Processor: Intel Core i7-7700 3.60 GHz
  • Memory: 32GB DDR4 Ram
  • Storage: 1TB Solid State Drive (SSD) Fast Boot + Storage
  • Operating System: Windows 11 Pro (64-bit)
const node = document.querySelector('#card');
const rect = node.getBoundingClientRect();
console.table({
  x: rect.x,
  y: rect.y,
  width: rect.width,
  height: rect.height,
  devicePixelRatio: window.devicePixelRatio
});

A one-pixel CSS border is not guaranteed to occupy exactly one physical pixel at every scale. Test the complete mapping: CSS coordinate × scale. If that product is fractional, the edge can be blended across pixels.

Control html2canvas’s scale explicitly

const canvas = await html2canvas(document.querySelector('#card'), {
  scale: 1,
  backgroundColor: '#ffffff'
});

document.body.appendChild(canvas);

Try scale: 2 as a separate experiment when you need a higher-resolution export. Do not assume a larger scale removes antialiasing; it changes the pixel grid and can move the artifact rather than eliminate it. Also check whether your application later resizes the canvas with CSS or draws it into another canvas.

Avoid fractional transforms in the capture clone

Values such as transform: translate(0.5px, 0), scaled ancestors, and rotations intentionally place edges between pixels. They may be visually desirable in the live page but unsuitable for a pixel-exact export. Remove or replace them in the export-only copy rather than changing the production layout.

Rank #2
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Blush
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.

Isolate CSS support and style interactions

When alignment tests do not change the result, treat the border as a CSS reconstruction problem. html2canvas’s own guidance is to create a reproducible test case when a property is missing or incomplete. The fastest method is binary reduction: remove half of the visual declarations, render again, then narrow the remaining set.

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.

Test shadows and rounded corners first

A reported html2canvas 1.4.1 issue describes a coarse dark border when border-radius and box-shadow are combined. That is an individual report from September 9, 2022, tested in the then-current Edge and Chrome on Windows 11—not proof that every version or browser has the same defect. It is nevertheless a useful reproduction pattern.

.capture-debug {
  border-radius: 0 !important;
  box-shadow: none !important;
  transform: none !important;
  filter: none !important;
}

If removing those declarations fixes the export, decide whether a simpler equivalent is acceptable: a solid border instead of a shadow, a pre-rendered asset, or an export-only style. If the minimal case still fails, verify the html2canvas version and test in another browser to distinguish a browser-specific result from a library limitation.

Rank #3
Sale
HP Essential 2026 Laptop Student Business, Ultra Light, 4GB RAM, Intel CPU
  • Performance: Powered by Intel Celeron N4500 dual-core processor with up to 2.8 GHz burst frequency and 4MB L3 cache, this HP Chromebook delivers smooth multitasking for everyday computing. With 4GB LPDDR4x-2933 RAM and Intel UHD Graphics, enjoy seamless web browsing, video streaming, and productivity apps. Chrome OS boots in seconds and updates automatically, keeping your laptop secure and running at peak performance for students, professionals, and home users.
  • Immersive 14-Inch HD Display: Experience clear, vibrant visuals on the 14-inch diagonal HD (1366 x 768) anti-glare display with 250 nits brightness and 62.5% sRGB color accuracy. The micro-edge design maximizes your viewing area with an impressive 80% screen-to-body ratio, perfect for streaming movies, video calls, and document editing. The anti-glare coating reduces eye strain during extended use, making it ideal for all-day productivity and entertainment in any lighting condition.
  • Advanced Connectivity & Ports: Stay connected with Wi-Fi 6 (2x2) for faster wireless speeds and Bluetooth 5.3 for seamless device pairing. Equipped with versatile ports including 1 USB Type-C 10Gbps (with USB Power Delivery and DisplayPort 1.4), 2 USB Type-A 5Gbps ports, 1 HDMI 1.4b, and 1 headphone/microphone combo jack. Connect external monitors, transfer files quickly, charge your device, and expand your workspace effortlessly for maximum productivity and flexibility.
  • All-Day Battery & Premium Design: The battery keeps you powered throughout your day, while the included 45W USB Type-C power adapter ensures fast charging. Featuring a sleek modern grey finish with vertical brushing pattern on the keyboard deck, this lightweight 3.35 lb Chromebook combines style and portability. The full-size modern grey keyboard and HP Imagepad provide comfortable typing and precise navigation for work, school, or entertainment on the go.
  • Enhanced Security & Multimedia: Built-in H1 secure microcontroller protects your data and privacy with enterprise-grade security. The HP True Vision 720p HD camera with integrated dual array digital microphones delivers crystal-clear video calls and online meetings. HD Audio with stereo speakers provides rich, immersive sound for music, videos, and calls. With 64GB eMMC storage, you have ample space for essential files while Chrome OS seamlessly integrates with Google Drive for cloud storage.

Use onclone for export-only changes

The onclone callback receives the cloned document html2canvas is about to render. It lets you change styles without mutating the live page.

const canvas = await html2canvas(document.querySelector('#card'), {
  scale: 2,
  onclone: (clonedDocument) => {
    const clonedCard = clonedDocument.querySelector('#card');
    clonedCard.style.boxShadow = 'none';
    clonedCard.style.borderRadius = '0';
    clonedCard.style.transform = 'none';
  }
});

Use this first as a diagnostic. If the clean clone exports correctly, keep only the changes that are acceptable for your output and document them as export styling.

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.

Why imageSmoothing: false usually does not fix borders

imageSmoothing controls interpolation when an image is scaled on a canvas. Setting it to false selects nearest-neighbor sampling, which is useful for pixel art or deliberately hard-edged source images. It is not a universal switch for antialiasing CSS borders, rounded corners, shadows, or transformed DOM geometry. Use it only when your investigation shows that a source image is being interpolated.

Rank #4
Dell Optiplex 3060 Desktop Computer | Intel i5-8500 (3.2) | 32GB DDR4 RAM | 1TB SSD Solid State | Built in WiFi | Bluetooth | Windows 11 Professional | Home or Office PC (Renewed)
  • [INTEL POWERED CONTENT] - Built with a 8th Generation Hexa-Core Intel i5 and 32GB of DDR4 RAM; Modern, Windows 11 ready, with 4K support, Executive multitasking, media streaming and smooth, multi-tab web browsing; Perfect as an all-purpose multimedia computer; built for content creators; Plenty of RAM and Mass storage for photo and video editing powered by Intel HD 630
  • [LATEST WIRELESS TECH] - This Dell Desktop Computer easily connects to the internet through the Built In WiFi / Bluetooth
  • [SOLID STATE STORAGE] - This Dell Computer setup comes with an ultra-fast 1TB Solid State Drive (SSD); Setup as the primary boot device; Boot and load programs with lightning speed ; Additional expansion available
  • [BUY & OWN WITH CONFIDENCE] - From the world's largest Microsoft Authorized Refurbisher; Quality Guarantee and Free Tech Support; Award-winning Customer Service; | Support Sustainable Business
  • [MODERN HI-SPEED PORTS] - USB 3.0 (x4) | USB 2.0 (x4) | DisplayPort (x1) | HDMI Port (x1) | Audio Combo Jack (x1) | Audio Out (x1) | RJ-45 Ethernet (x1) | Internal SATA (x3)
const ctx = canvas.getContext('2d');
ctx.imageSmoothingEnabled = false;
ctx.drawImage(sourceImage, 0, 0, targetWidth, targetHeight);

When to use a different capture route

Keep html2canvas when you need a DOM-based export and can make the relevant styles render acceptably. Replace or supplement it when you require the browser’s actual composited pixels, the page relies on CSS that html2canvas does not implement, or the artifact survives a minimal reproduction and export-only simplification.

For browser extensions, html2canvas’s FAQ points to browser-native screenshot APIs as an alternative. Native capture has a different permission and workflow model, so choose it only when your extension context supports it. For a server-side or automated workflow, a browser screenshot service can render the page in a real browser instead of reconstructing it from CSS.

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

Or skip the browser setup

ScreenshotNeo captures a URL through a website screenshot API, returning PNG, JPEG, WebP, or PDF. It can be useful when your goal is a faithful page capture rather than a client-side DOM reconstruction. Before capture, it accepts the cookie or consent banner like a visitor 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 identify the page verdict and billing result.

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

Use the API documentation at https://screenshotneo.com/docs/ for all options. The following calls are complete starting points; replace the URL and key with your values.

Best Value
Dell OptiPlex Computer Desktop PC, Intel Core i5 3rd Gen 3.2 GHz, 16GB RAM, 2TB HDD, New 22 Inch LED Monitor, RGB Keyboard and Mouse, WiFi, Windows 11 Pro (Renewed)
  • 🖥POWERFUL PROCESSOR and SUPERIOR STORAGE: Configured with top of the Intel Core i5 processor for lightning-fast, reliable and consistent performance to ensure an exceptional PC experience. 16GB RAM memory to smoothly run multiple applications and browser tabs all at once. 2TB HDD storage space to store apps, games, photos, music, and movies. Loaded with 16GB to zip through multiple tasks in a hurry without lag.
  • 🖥️New 22 Inch Full HD (1920x1080) LED monitor: with 75hz, High-Quality panel with quick refresh rate and response time. With 1080p resolution, you can enjoy gaming or a modern computing experience. 22 Inch monitor has a Smart Contrast to provide optimized image quality. Bezel-less and sleek design with glossy finish, crisp edge-to-edge visuals. Wide Viewing Angles for clarity from any viewpoint. VESA Mountable and built-in tilt options allow for a variety of monitor configurations.
  • ⌨️ +🖱️ RGB KEYBOARD AND MOUSE | RGB SPEAKER: 3 LED Colors - Blue, red, green, Backlight LED Lights for use at night time, looks amazing. The keyboard mouse and speaker are responsive, reliable, and probably plastered in RGB lights. It's important you pick the right one for your desktop.
  • 💿 WINDOWS 10 Pro LATEST: A new installation of the latest Microsoft Windows 11 Professional 64 Bit Operating System software, free of bloatware commonly installed from other manufacturers. As Microsoft's latest and best OS to date, Windows 10 Pro 64 Bit will maximize the utility of each PC for years to come. Optional software such as Anti-Virus and Office 365 can also be easily downloaded through the Microsoft Windows App Store.

cURL

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(`${res.status} ${res.statusText}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

Options relevant to border investigations

  • Choose a viewport or one of 12 device presets, set a retina scale, and capture full pages with lazy-loaded images.
  • Capture one element by CSS selector, hide selectors, click an element, or apply custom CSS and JavaScript.
  • Wait for a selector, a delay, or network idle; block ads, trackers, requests, or resource types.
  • Set headers, cookies, user agent, authorization, timezone, geolocation, transparent backgrounds, image resizing, and a cache TTL.
  • Use PDF paper size, margins, landscape mode, and page ranges; submit asynchronous jobs with signed webhooks; capture up to 100 URLs per bulk call; and monitor usage through the usage API.
  • Signed links support public <img> tags, and the OpenAPI specification plus commonly used screenshot parameter names can simplify migration.

ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. Every feature is on every plan: 1,000 shots per month are free with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Troubleshooting checklist

The border is gray only in the downloaded file

  • Open the file at native size and inspect its pixel dimensions.
  • Remove any post-export CSS resizing or secondary canvas draw.
  • Test an explicit integer scale and integer-aligned geometry.

The border becomes coarse or black around rounded corners

  • Reproduce with border-radius and box-shadow removed independently.
  • Use onclone to disable the triggering declaration only for export.
  • Record the html2canvas version and browser; do not generalize one reported version-specific issue to all environments.

Changing scale does nothing

  • Confirm that the artifact exists in the native bitmap, not only in its display.
  • Reduce the page to one element and remove filters, transforms, pseudo-elements, and nested shadows.
  • Check for an unsupported or partially supported CSS property; a scale change cannot implement missing CSS support.

The result is blank or incomplete

  • Wait for the target element or its assets before calling html2canvas.
  • Check cross-origin image restrictions and resource loading separately from border rendering.
  • Capture a smaller minimal reproduction before changing multiple variables at once.

Practical decision rule

If the artifact follows fractional coordinates or a resize, fix alignment and the output pipeline. If it follows one CSS declaration or combination, use a cloned export style or simplify that effect. If it survives both tests and the required appearance depends on CSS html2canvas cannot reconstruct, use a browser-native or real-browser capture route instead. The affected markup, styles, html2canvas version, browser, scale, and bitmap/display dimensions determine the final fix.

Frequently Asked Questions

Does setting the border color to a darker value remove the grayscale effect?

Not reliably. If antialiasing is blending the edge or a CSS interaction is being reconstructed incorrectly, changing the color only changes the blended result.

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

Should I always export at devicePixelRatio?

No. That is html2canvas’s documented default, but an explicit integer scale may make alignment easier to diagnose. Choose the scale that matches your required output dimensions.

Can a browser screenshot service preserve a page’s authenticated state?

Only when the service supports and is configured with the required cookies, headers, or authorization. ScreenshotNeo exposes custom headers, cookies, user agent, and Authorization options; supply credentials carefully.

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
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

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.