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.

To include an element hidden with CSS in an html2canvas image, reveal it in html2canvas’s cloned document with the onclone callback—not in the live page. Find the element in the clone and remove the hiding style, including any hidden ancestor that prevents it from rendering. Then ensure the revealed element has the size and position you want in the output.

Why html2canvas omits hidden elements

html2canvas does not take a native screenshot of the browser’s pixels. It traverses the DOM and reconstructs an image from page information and CSS properties it supports. Its visibility reference test treats elements styled display: none and visibility: hidden as hidden in the rendered result. Merely asking html2canvas to capture a hidden element does not make it visible.

The project documents onclone as a callback for modifying the cloned document that html2canvas renders. Changes there do not affect the original source document, making the callback the natural approach when the element should appear in the image but must not flash into view for users.

The examples below show the implementation pattern. Choose selectors and styles that fit your page; the callback is documented, but the exact CSS needed to restore a particular element’s layout depends on your application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Reveal the element in the cloned document

Example: a target hidden with display:none

Give the target a stable selector, then set an appropriate display value in the clone. Replace .receipt-preview with a selector for your element. If it should participate in normal layout, a value such as block may be suitable; if it is a flex or grid container, restore the corresponding display mode instead.

const target = document.querySelector('.receipt-preview');

if (!target) {
  throw new Error('Could not find .receipt-preview');
}

const canvas = await html2canvas(target, {
  onclone: (clonedDocument) => {
    const clonedTarget = clonedDocument.querySelector('.receipt-preview');

    if (clonedTarget) {
      clonedTarget.style.display = 'block';
    }
  }
});

document.body.appendChild(canvas);

The target passed to html2canvas is the element from the original document, while onclone receives the cloned document. Select the corresponding element in the clone and change its styles there. The original target stays hidden on the live page.

Example: a target hidden with visibility:hidden

For visibility: hidden, set the clone’s visibility to visible. Unlike display: none, visibility-hidden elements generally retain layout space, so changing visibility may be enough when their geometry is already correct.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
const target = document.querySelector('.receipt-preview');

if (!target) {
  throw new Error('Could not find .receipt-preview');
}

const canvas = await html2canvas(target, {
  onclone: (clonedDocument) => {
    const clonedTarget = clonedDocument.querySelector('.receipt-preview');

    if (clonedTarget) {
      clonedTarget.style.visibility = 'visible';
    }
  }
});

document.body.appendChild(canvas);

When a parent is hidden too

Check the target’s ancestors. If a parent has display: none or visibility: hidden, making only the child visible may not make it render. Reveal the necessary ancestor in the clone as well, and consider what restoring that ancestor means for the target’s size and placement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const canvas = await html2canvas(target, {
  onclone: (clonedDocument) => {
    const clonedPanel = clonedDocument.querySelector('.preview-panel');
    const clonedTarget = clonedDocument.querySelector('.receipt-preview');

    if (clonedPanel) {
      clonedPanel.style.display = 'block';
      clonedPanel.style.visibility = 'visible';
    }

    if (clonedTarget) {
      clonedTarget.style.display = 'block';
      clonedTarget.style.visibility = 'visible';
    }
  }
});

Only change what is necessary. A hidden element may have been intentionally removed from layout or positioned for a different interaction state. If you reveal a whole panel, its surrounding layout can change in the clone; set appropriate dimensions, positioning, or other styles if the captured composition requires them.

Choose the right capture approach

Approach What happens Best fit
Modify the clone with onclone The rendered clone gets the visibility and layout changes; the source document is not changed by those edits. Include hidden content without changing what a visitor sees on the live page.
Temporarily change the live DOM The actual page is changed while the content is revealed. Depending on timing and rendering, that state could be visible to a user. Only when changing the live page is acceptable and the application controls the timing and restoration.
Use ignoreElements or data-html2canvas-ignore The matching element is excluded from the output. Omit unwanted controls or other content—not capture a hidden target.
Use a browser-native screenshot capability The browser captures rendered pixels rather than reconstructing the page through html2canvas. When pixel-level fidelity is the requirement and the browser or environment offers an appropriate capture method.

The html2canvas FAQ advises against using html2canvas in browser extensions, where browser tab screenshot support is available. The exact native method depends on the browser and execution environment.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Account for layout, CSS, and images

Restore useful geometry

An element with display: none has no rendered layout box while hidden, so its dimensions may not be useful until it is displayed. After revealing it in the clone, check whether it has the intended width, height, and position. If it should appear in a specific spot rather than affect surrounding content, set clone-only positioning or dimensions that reproduce the desired composition.

For an element whose content extends beyond the viewport, html2canvas’s FAQ suggests setting windowWidth and windowHeight to the target’s scrollWidth and scrollHeight to address viewport sizing or clipping:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const canvas = await html2canvas(target, {
  windowWidth: target.scrollWidth,
  windowHeight: target.scrollHeight,
  onclone: (clonedDocument) => {
    const clonedTarget = clonedDocument.querySelector('.receipt-preview');
    if (clonedTarget) clonedTarget.style.display = 'block';
  }
});

This sizing option does not reveal a hidden element by itself. It also cannot guarantee an arbitrarily large canvas: browser, operating system, and hardware limits vary.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Check the styles the renderer can reproduce

The project’s online feature reference lists display, opacity, and visibility among supported CSS properties. Supported means html2canvas handles those properties; it does not mean the renderer overrides styles that hide content. The same reference lists limitations including filter, object-fit, box-shadow, mix-blend-mode, and zoom; transforms have limited support. Revealing an element therefore does not guarantee its appearance will exactly match a browser-native screenshot. The online feature reference does not identify a release or version, so check the behavior of the version installed in your project when investigating a version-specific issue.

Check images loaded from other origins

Changing visibility does not change browser origin rules. Images from the page’s own origin are the straightforward case. For images hosted elsewhere, html2canvas documents CORS- and proxy-related configuration; its FAQ notes that a proxy may be needed for images outside the page’s origin. Options such as useCORS, proxy, and allowTaint do not override browser security policy. Configure the image host to permit the required cross-origin access or use an appropriate proxy where necessary.

Troubleshooting hidden-element captures

Symptom Likely cause What to check
The target is still missing. The callback did not find the corresponding node, or a hidden ancestor still prevents rendering. Confirm the selector exists in clonedDocument; inspect the target and its ancestors for hiding styles and reveal the necessary nodes in the clone.
The image is blank or clipped. The target has unsuitable layout dimensions, extends beyond the capture viewport, or the canvas is too large for the environment. Give the revealed element useful geometry. For viewport sizing, try windowWidth and windowHeight based on its scroll dimensions; remember canvas limits vary across environments.
The element appears, but its design differs. Its appearance depends on CSS that html2canvas does not support fully, or the restored styles do not match the intended state. Check the project’s supported-features reference and simplify or adjust styles in the clone. Consider native browser capture if exact rendered pixels are essential.
An image inside the target is absent or the exported canvas is tainted. A cross-origin image lacks the required CORS access, or a proxy is needed. Check the image server’s CORS configuration and html2canvas’s proxy/CORS options. These settings cannot bypass browser origin policy.
The target is unexpectedly omitted despite being visible. It may match an exclusion rule. Check whether ignoreElements or data-html2canvas-ignore applies to the target or one of its descendants; remove the exclusion if that content belongs in the output.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a website screenshot rather than an image reconstructed from a page in your own browser, ScreenshotNeo can return a screenshot or PDF from one GET request. It accepts the site’s cookie or consent banner like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response reports the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents.

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

Install Python’s requests package if needed, then run this example with your API key and the URL to capture. It saves the returned image bytes as shot.webp. See the ScreenshotNeo documentation for request options and response details.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
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)

The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

What html2canvas can and cannot promise

The clone hook solves a specific problem: changing the DOM state html2canvas renders without changing the live source document. It does not turn html2canvas into a native screenshot tool, guarantee exact visual fidelity, supply layout dimensions for every hidden design, or bypass cross-origin restrictions. If the output must match the browser’s rendered pixels precisely, evaluate a browser-native capture method in the environment where the capture will run.

Frequently Asked Questions

Does html2canvas support CSS visibility?

Its online feature reference lists visibility as supported, but that does not mean html2canvas will override a rule that hides an element.

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

Can I capture an element hidden by a parent?

Yes, if you reveal the necessary hidden parent in the cloned document as well as the target; the result depends on the parent’s layout and styles.

Does onclone modify the page visitors see?

The documented callback modifies the cloned document used for rendering, not the original source document.

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.