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
World desk7 min

How to Fix html2canvas Not Applying Styles from External CSS Files

A practical diagnostic guide for html2canvas captures that ignore external CSS, including DevTools checks, CORS distinctions, supported-property testing and a server-side alternative.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Start by separating three causes: the browser did not load or apply the stylesheet, html2canvas cannot read a cross-origin stylesheet, or the CSS property is not implemented by html2canvas. Check the live page’s computed styles first, then inspect the cloned capture and the library’s supported features. Setting useCORS: true does not make external CSS readable; that option is for images.

How html2canvas handles external CSS

html2canvas is not a native screenshot tool. It reconstructs a rendering from the DOM and style information it can inspect, then paints that representation to a canvas. Because it does not copy the browser’s final bitmap, its output can differ from what you see on screen. The project documents this rendering model and its limitations in the documentation.

That distinction explains why a page can look correct in Chrome while a capture loses colors, spacing, fonts, effects or layout. Diagnose the page in this order: browser loading and cascade, stylesheet access, then CSS feature support.

1. Verify that the browser loaded and applied the stylesheet

Inspect the request

  1. Open DevTools and select Network.
  2. Reload the page with the Network panel open.
  3. Find each CSS request. Check its status, final URL after redirects, response content and whether a later request failed or was blocked.
  4. Open the response and confirm that the expected selector and declarations are actually present.

A 404, an incorrect relative URL, a MIME or content-security error, or a stylesheet loaded after your capture call can all produce an apparently unstyled canvas. Fix the ordinary page first; html2canvas cannot reproduce rules that the browser never received.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Lexar D40E 128GB Dual USB 3.2 Gen 1 Type-C Jump Drive, Champagne Silver
  • USB-C 2-in-1 storage OTG: The Lexar JumpDrive Dual Drive D40E features USB Type-A and Type-C connectors in a slim, portable form factor for easy device compatibility
  • Transfer speeds up to 100MB/s: Based on internal testing, performance may vary depending upon the host device, interface, and usage conditions. 1MB=1,000,000 bytes
  • Plug and Play: Widely compatible with USB Type-C smartphones, tablets, laptops, Macs, and traditional Type-A devices, no software installation required. The 360° swivel design allows for easy switching between connectors without the hassle of losing a cap
  • Durable & Compact: The Lexar D40E USB memory stick features a metal enclosure, withstands temperatures from 0° to 50° C (32°F to 122°F), and is lightweight at 26g with dimensions of 70.4 x 16.9 x 11.7mm
  • Security & Warranty: Securely protects files using an advanced security software solution with 256-bit AES encryption. Backed by a Lexar 3-year limited warranty

Inspect computed styles, not just the source file

Select the element you capture and open Computed styles. Confirm the actual values for properties such as display, color, background-color, font-family, font-size, width and margin. Also check selector matching, media queries, cascade order and inline overrides. If the expected values are absent here, this is a normal CSS debugging problem rather than an html2canvas problem.

Wait until styles are ready

Call html2canvas only after the stylesheet has loaded and any fonts or application-rendered content are ready. In an application, place the capture behind the component’s loaded state. A simple diagnostic is to add a short delay and compare results; a reliable implementation should instead wait for the real readiness signal.

await document.fonts.ready;
const canvas = await html2canvas(document.querySelector('#invoice'));

2. Compare the live element with the captured clone

If DevTools shows the expected computed styles, capture a small element rather than the entire page. Compare each computed property with the canvas output. This narrows the problem to html2canvas’s cloned document, capture context or CSS support.

Use a minimal reproduction

Remove unrelated scripts and styles, keep one external stylesheet and one target element, and reproduce with the installed html2canvas version. This reveals whether a framework, shadow DOM boundary, animation, media query or application timing is involved.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
KOOTION USB C Flash Drive 32GB 2 in 1 OTG USB 3.0/Type C Thumb Drive Dual Drive USB C Memory Stick for Smartphone Laptop Tablet PC, Blue
  • 2 in 1: USB C + USB 3.0, 32GB usb c flash drive has dual ports, usb 3.0 port is applied to all devices which have usb 3.0 interface and usb c port is widely used in all Android smartphones with OTG function
  • High Speed USB 3.0: Read speed up to 90 MB/s, Write speed up to 30 MB/s, the speed of USB 3.0 interface is faster than USB 2.0, save time to wait, increases work productivity. Note: Speed will be limited if you use the USB key in the USB 2.0 interface
  • Large Compatibility: The USB 3.0 Connector is compatible with USB 3.0 & USB 2.0 backward USB 1.1 devices, such as Laptop, Desktop, Car Audio, Tablet, TV, Speakers, Projector. USB-C port is compatible with all Android Smartphones
  • Expand Storage: Good performance in storing, transferring and sharing digital data with families, friends, colleagues, customers. It can expand the capacity of smartphone, you can watch movies or share pictures when you go on vacation with your family
  • Note: Make sure your smartphone is equipped with OTG function and need to open OTG function in Settings when you plug memory stick, then you can transfer easily data bewteen different devices
import html2canvas from 'html2canvas';

const target = document.querySelector('#card');
const canvas = await html2canvas(target, {
  backgroundColor: '#ffffff',
  logging: true
});
document.body.appendChild(canvas);

Logging can expose resource-loading and parsing clues. Do not assume that changing the stylesheet URL or adding a CORS flag can repair an unsupported rendering feature.

3. Understand stylesheet CORS versus image CORS

What a stylesheet access error means

Browsers can prevent script from reading cssRules on a cross-origin stylesheet. A SecurityError while inspecting document.styleSheets is therefore a stylesheet access issue. The html2canvas FAQ explains the browser security boundary and its limitations: FAQ.

Neither useCORS nor proxy grants general access to foreign CSS rules. They are documented for loading images used in the capture. A server must explicitly permit the requesting origin where direct image loading is used.

Find the sheet that throws

for (const sheet of document.styleSheets) {
  try {
    console.log(sheet.href, sheet.cssRules.length);
  } catch (error) {
    console.warn('Cannot read stylesheet:', sheet.href, error);
  }
}

An issue report records Firefox cases where an injected extension stylesheet triggered a cssRules error: issue 2197. This is a reported possibility, not a universal explanation. Reproduce in a clean browser profile and compare the list of stylesheets if the error appears inconsistent.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Lexar D40E 64GB Dual USB 3.2 Gen 1 Type-C Jump Drive, Champagne Silver
  • USB-C 2-in-1 storage OTG: The Lexar JumpDrive Dual Drive D40E features USB Type-A and Type-C connectors in a slim, portable form factor for easy device compatibility
  • Transfer speeds up to 100MB/s: Based on internal testing, performance may vary depending upon the host device, interface, and usage conditions. 1MB=1,000,000 bytes
  • Plug and Play: Widely compatible with USB Type-C smartphones, tablets, laptops, Macs, and traditional Type-A devices, no software installation required. The 360° swivel design allows for easy switching between connectors without the hassle of losing a cap
  • Durable & Compact: The Lexar D40E USB memory stick features a metal enclosure, withstands temperatures from 0° to 50° C (32°F to 122°F), and is lightweight at 26g with dimensions of 70.4 x 16.9 x 11.7mm
  • Security & Warranty: Securely protects files using an advanced security software solution with 256-bit AES encryption. Backed by a Lexar 3-year limited warranty

When useCORS is appropriate

Use it for remote images inside the region being captured, and only when the image server returns a suitable Access-Control-Allow-Origin header:

const canvas = await html2canvas(document.querySelector('#gallery'), {
  useCORS: true
});

If the image server cannot provide that header, configure an appropriate same-origin proxy. The official examples show both approaches: html2canvas examples. Neither approach makes an external CSS file’s rules readable.

4. Check whether the CSS property is supported

html2canvas implements CSS properties manually, and support is incomplete. A valid stylesheet can therefore be applied by the browser yet be missing from the canvas. Review the project’s supported features and FAQ and the configuration reference.

Typical support investigation

  1. Identify the exact missing property, rather than describing the result as “CSS did not load.”
  2. Check whether that property is listed as supported or has known limitations.
  3. Temporarily replace it with a simpler equivalent, such as a solid background instead of a complex effect.
  4. Reduce the page to a minimal test case. If the property is missing or incomplete, follow the project’s guidance to create a test case and open an issue.

Properties involving advanced filters, blending, complex shadows, generated content, newer layout behavior or browser-only effects are especially worth testing individually. Do not infer unsupported behavior from a single missing declaration; verify the property and the installed version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
2-Pack 128GB USB C Flash Drive Dual Type C + USB A Memory Stick Jump Drive 2-in-1 Thumb Drive for Storage and Backup (128GB*2 Black&Blue)
  • 2-in-1 Dual Design: Features both USB-C and USB-A connectors, making it compatible with phones, tablets, MacBooks, PCs, and laptops-no adapter needed
  • Wide Compatibility: Works seamlessly with USB A and USB C devices, ensuring reliable file transfers across smartphones, computers, and more
  • Ample Storage Options: Available in 16GB/32GB/64GB/128GB providing plenty of space for photos, videos, music, and documents
  • Portable & Lightweight: Compact and durable design for travel, school, or daily use-take your files anywhere
  • Plug-and-Play Convenience: No software or drivers required; simply insert into USB-C or USB-A ports and start transferring files instantly

5. Check redirects and the version you actually installed

Inspect the final URL for every image and stylesheet request, not only the URL in your HTML. A same-origin image URL can redirect to a CDN and change the origin involved in CORS handling. A maintainer issue describes this image-specific edge case: issue 2892. It does not prove that redirected CSS causes every missing-style symptom.

Record the html2canvas version from your lockfile or package manager, then test against that version. Behavior described in an old issue may not match your release. Verify response headers and final origins in DevTools before changing code.

Practical fixes by symptom

Symptom Likely cause Action
Styles absent in DevTools Computed panel URL, timing, selector, media or cascade problem Fix the page stylesheet and wait for its loaded state.
Computed styles correct, canvas plain Unsupported property or clone/capture context Test the exact property and create a minimal reproduction.
SecurityError for cssRules Cross-origin or injected stylesheet Identify the sheet; use same-origin CSS or appropriate server configuration. Test a clean profile.
Remote images missing or canvas tainted Image CORS or redirect Use useCORS: true with the required response header, or a same-origin proxy; inspect the final URL.
Only one browser fails Browser security or version-specific behavior Compare browsers, profile extensions and installed html2canvas version.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Capture reliability and performance

  • Capture the smallest necessary element; full-page canvases consume more memory and take longer.
  • Wait for fonts, images and asynchronous UI before calling html2canvas.
  • Disable transitions and animations during capture so layout does not change mid-render.
  • Use a deterministic viewport, color scheme and data state when comparing output.
  • Keep a browser screenshot as the reference. html2canvas output is a reconstruction, not a pixel copy.

Or skip the browser setup

When you need a server-side screenshot rather than a canvas reconstruction, ScreenshotNeo accepts one GET request and returns PNG, JPEG, WebP or PDF. Before capture it accepts consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info and capture_pdf for 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.

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)
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}`);

See the full parameter list and response details in the ScreenshotNeo documentation. Create a free account to start with 1,000 screenshots per month and no card.

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

Frequently Asked Questions

Does copying the external CSS into a style tag always fix html2canvas?

No. It can remove a cross-origin stylesheet access problem, but unsupported CSS properties, timing, images and clone-specific behavior can still affect the result.

Best Value
Samsung Type-C USB Flash Drive 256GB, USB 3.2 Gen 1, Up to 400MB/s
  • USB-C STORAGE ON THE GO: This sleek drive is supported by Samsung NAND flash and is incredibly compact to fit in the palm of your hand; Count on reliable performance and fast transfer speeds while staying compact
  • PERFORMANCE WITH SPEED: No need to choose between performance and reliability; Experience a fast, powerful flash drive that transfers 4GB files in just 11 seconds with up to 400MB/s USB 3.2 Gen 1 read speeds and is backward compatible with USB 3.0/2.0
  • MODERN MEETS ICONIC: The ultra-sleek USB-C drive looks as good as it performs; Featuring a reversible plug, the Type-C inserts into your devices seamlessly every time; Transfer large files with style and ease
  • ALWAYS CONNECTED: USB-C is compatible across devices, including laptops, tablets, phones and cameras, with enough space for 63,730 photos or maximum 12 hours of 4K video; With up to 256GB of storage space, this pocket-sized thumb drive comes in handy wherever you go
  • TOUGH & TRUSTED: Files stay secure, no matter the terrain; Samsung's flash memory technology makes the Type-C a trustworthy drive to store your valuable data; It's waterproof, shock-proof, magnet-proof, temperature-proof, and X-ray-proof body, plus it's backed by a 5-year limited warranty

Should I switch to a proxy for every missing style?

No. A proxy is relevant to cross-origin image loading and must be configured appropriately. It is not a general way to make foreign CSS rules readable.

How can I prove a browser extension is involved?

Repeat the capture in a clean browser profile, inspect document.styleSheets, and compare which sheet produces the cssRules error.

The Bottom Line

First verify the stylesheet request and computed styles. Then separate stylesheet CORS from image CORS, and finally test the exact CSS property against html2canvas’s support. These checks identify whether you need a page fix, server headers, a proxy for images, a simpler style, or a different screenshot method.

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.

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.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
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.