To capture several divs with html2canvas, either capture their shared parent once or select each div and call html2canvas() for it. The function captures one element per call and returns a Promise for a canvas. Use Promise.all() when you need separate canvases at the same time; draw those canvases onto a second canvas if you need one combined image.
Choose between capturing a wrapper and capturing each div
The right approach depends on whether you need to preserve the page’s arrangement or handle each result separately. html2canvas reconstructs a rendering from DOM information; it is not a direct screenshot of the browser’s pixels.
| Approach | Best when | Layout and output | Trade-off |
|---|---|---|---|
| Capture a shared wrapper | The divs belong together and should appear as they do in the page layout. | One canvas representing the wrapper and its rendered layout. | You have less independent control over the output position and size of each div. |
| Capture each div separately | You need separate images, or want to position the results yourself. | One canvas per selected div; you can append them or composite them. | You must decide the output arrangement and account for canvas memory and dimensions. |
If preserving the spacing, alignment, and other relationships between elements is more important than getting separate files, capture their common parent. If you need independent outputs or a custom arrangement, capture each element.
Capture multiple divs as separate canvases
Load html2canvas in a browser-based application, select the elements, and await a call for each one. The official getting-started documentation describes the result as a Promise that resolves with a canvas element.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- 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)
Runnable browser example
In your HTML, give the divs a shared selector and provide a destination element for the output:
<div class="capture">First panel</div>
<div class="capture">Second panel</div>
<div id="results"></div>
In a browser JavaScript module where html2canvas is installed and available to the bundler, capture each matching element:
import html2canvas from '@html2canvas/html2canvas';
async function captureDivs() {
const divs = [...document.querySelectorAll('.capture')];
const result = document.querySelector('#results');
if (!result) {
throw new Error('Missing #results element');
}
if (divs.length === 0) {
throw new Error('No elements matched .capture');
}
const canvases = await Promise.all(
divs.map((div) =>
html2canvas(div, {
backgroundColor: null,
scale: window.devicePixelRatio,
useCORS: true,
})
)
);
result.replaceChildren(...canvases);
return canvases;
}
captureDivs().catch((error) => {
console.error('Could not capture the divs:', error);
});
The selector determines which elements are captured, and the array order is the order in which the canvases are returned. Promise.all() lets the capture operations proceed asynchronously and resolves to an array in that same input order. If any capture rejects, the combined Promise rejects; handle that error rather than assuming all canvases were produced.
The example appends canvases to the page so you can inspect them. To download, upload, or display them elsewhere, use the export or composition methods below. If your divs need the exact spacing and relative placement already present in the page, replace the loop with one call on their common wrapper:
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →const wrapper = document.querySelector('#capture-wrapper');
if (!wrapper) throw new Error('Missing #capture-wrapper');
const canvas = await html2canvas(wrapper, { useCORS: true });
Combine separate captures into one image
Capturing multiple elements returns multiple canvases; it does not automatically merge them. To create one image, make a destination canvas, calculate its size for the arrangement you want, and draw each source canvas at the appropriate coordinates.
Rank #2
- 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.
Stack captures vertically
This example places the results one below another, using the widest source canvas as the destination width. It assumes the canvases have already been captured.
function stackVertically(canvases) {
if (canvases.length === 0) {
throw new Error('No canvases to combine');
}
const width = Math.max(...canvases.map((canvas) => canvas.width));
const height = canvases.reduce((sum, canvas) => sum + canvas.height, 0);
const destination = document.createElement('canvas');
destination.width = width;
destination.height = height;
const context = destination.getContext('2d');
if (!context) throw new Error('Could not create a 2D canvas context');
let y = 0;
for (const canvas of canvases) {
context.drawImage(canvas, 0, y);
y += canvas.height;
}
return destination;
}
For a horizontal row, use the maximum source height as the destination height, sum the source widths, and advance an x coordinate by each canvas’s width after drawing. For a grid or custom layout, calculate each position explicitly. Canvas width and height are in pixels: when using a high-DPI scale, use the resulting canvas dimensions rather than assuming they equal the elements’ CSS dimensions.
Do not let a source canvas extend beyond the destination canvas: the excess will be clipped. A transparent destination is useful when the result should retain transparency. If you want a solid background, fill the destination canvas before drawing the sources.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Export the result
Use the canvas API to produce a PNG data URL or a Blob. A Blob is generally the more practical choice for large images or uploads because a base64 data URL can consume substantial memory.
Download as PNG
function downloadCanvas(canvas, filename = 'capture.png') {
canvas.toBlob((blob) => {
if (!blob) {
console.error('Canvas export failed');
return;
}
const link = document.createElement('a');
const objectUrl = URL.createObjectURL(blob);
link.href = objectUrl;
link.download = filename;
link.click();
URL.revokeObjectURL(objectUrl);
}, 'image/png');
}
Call downloadCanvas(destination) for a composite, or call it with an individual returned canvas. If another API requires a data URL, use canvas.toDataURL('image/png') for a modest output, but prefer toBlob() for larger files.
Rank #3
- 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.
Options that control what gets captured
Pass options as the second argument to html2canvas(element, options). These settings affect the rendered output, the selected area, and whether external resources can appear.
scale: Controls output resolution. The default is the browser’s device-pixel ratio; explicitly settingwindow.devicePixelRatiois a documented high-DPI pattern. A higher scale produces more pixels and can increase memory use and the risk of reaching browser canvas-size limits.backgroundColor: Set tonullto preserve transparency when the captured content has no background. Choose a color when you want a solid background.x,y,width, andheight: Define the capture region. Check that the requested crop matches the element’s position and the output you intend; a crop that excludes content will produce an apparently cut-off result.useCORS: Attempts to load cross-origin images using CORS. It cannot make an image readable if the image server does not permit the request.proxy: Can load permitted cross-origin resources through a proxy that returns them as same-origin data. The proxy must be configured to retrieve those resources; this is not a way to bypass browser content restrictions.ignoreElementsanddata-html2canvas-ignore: Exclude elements such as buttons, selection handles, or other UI that should not appear in the output.onclone: Adjusts the temporary cloned document used for rendering. Use it for capture-specific changes without altering the live page.windowWidthandwindowHeight: Control the viewport used for media queries and off-screen layout. If output is clipped because the rendered viewport is too small, align these values with the page’s scroll dimensions.
For multiple divs, pass the options to each call, or pass them to the single wrapper capture. A setting that changes one element’s appearance can also affect the result when capturing the larger parent.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsTroubleshoot missing, blank, or clipped output
Remote images are missing or the canvas cannot be exported
Cross-origin images are subject to browser content policy. The project’s official FAQ states, “html2canvas cannot circumvent content policy restrictions set by your browser.” Set useCORS: true only when the remote server sends suitable CORS headers. If the resource is permitted and you control the setup, a proxy that returns it as same-origin data may help. Without the necessary permission, the image may be omitted or the canvas may be tainted so it cannot be read or exported.
An iframe’s content is absent
Cross-origin iframes cannot be rendered through html2canvas because the browser does not allow access to their contentDocument. Capturing the parent element does not remove that restriction. If the iframe is on another origin, use an approach that has legitimate access to that content rather than expecting html2canvas to read it.
The result is cut off
- Check that you selected the intended element or wrapper and that its layout includes all of the content.
- Review
x,y,width, andheightif you set a crop. - For off-screen content or media-query differences, check
windowWidthandwindowHeight; the rendering viewport may need to match the relevant scroll dimensions. - When combining canvases, verify that the destination dimensions include every source canvas and that each draw position is correct.
The output is blank or truncated on a very large page
Browsers impose canvas-size limits. A capture that exceeds them can be blank or truncated. Capture smaller regions or elements separately and composite them, while keeping the destination canvas within a manageable size. Splitting reduces the size of individual captures but does not guarantee that an enormous final composite will fit; its own dimensions still matter.
Rank #4
- [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)
The wrong elements appear, or an element is missing
Check that querySelectorAll() matches the elements you intend to capture. If controls or overlays should be excluded, use ignoreElements or mark them with data-html2canvas-ignore. For capture-only styling, make changes in onclone so the live document is not changed.
The code runs in Node.js but no image is produced
html2canvas relies on browser APIs and is not a Node.js screenshot renderer. Run it in a browser context with a rendered document. If the requirement is to capture a live website from a server-side request, use a browser-based rendering service or API instead.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Performance, reliability, and implementation choices
Every captured element produces a canvas, and each canvas uses memory proportional to its pixel dimensions. Capturing at a higher scale or capturing many large elements can increase memory use. If you only need the page’s combined visual appearance, capturing a shared wrapper avoids creating a separate output canvas for every div. If you need individual assets, keep the captures limited to the elements and resolution you actually need.
Parallel calls through Promise.all() are concise and preserve element order in the resulting array, but all requested results remain in memory for composition or export. For a large set of elements, capture in smaller batches and release references to canvases when they are no longer needed. If one operation fails, handle the rejected Promise and decide whether the application should report the failure or retry after correcting the underlying cause.
html2canvas is best suited to browser-side captures of content the page can render and access. It does not override CORS restrictions, gain access to cross-origin iframe documents, or replace a browser screenshot engine in Node.js. For large outputs, consider splitting the work, choosing an appropriate scale, and exporting with a Blob.
Best Value
- 🖥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.
Or skip the browser setup
If you need a screenshot of a URL rather than canvases from elements in your own page, ScreenshotNeo is a website screenshot API and MCP server. A GET request returns a PNG, JPEG, WebP, or PDF. For example, save a WebP screenshot with cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. ScreenshotNeo accepts cookie/consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for 1,000 free screenshots a month, with no card required.
Frequently Asked Questions
Does html2canvas capture multiple divs with one call?
One call captures one element. To preserve the arrangement of several divs, pass their shared parent to one call; otherwise, make one call per div.
Can html2canvas capture a cross-origin iframe?
No. The browser prevents access to a cross-origin iframe’s document, so html2canvas cannot render its contents.
Can I use html2canvas as a Node.js website screenshot tool?
No. It relies on browser APIs and is intended for browser-side rendering, not as a Node.js screenshot engine.
Quick Recap
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.




