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

You cannot pass multiple div IDs, an array of elements, or a NodeList as one capture target to html2canvas. Its documented call takes one element. If the divs share a parent that contains only the content you want, capture that parent; otherwise, capture each div separately and draw the resulting canvases onto a new canvas if you need one combined image.

Can you pass multiple IDs to html2canvas?

No. An ID is a way to find an element in the DOM; it is not a special multi-element argument for html2canvas. The documented pattern is html2canvas(element, options?): give it one element, and it returns a Promise that resolves to a canvas. The official Getting Started and Examples pages, accessed September 29, 2026, demonstrate selecting one element at a time; they do not document passing an array or NodeList.

Choose the capture root based on the output you want:

  • One page-layout image: capture a shared wrapper containing the divs. Their position and spacing within that wrapper are retained as part of its rendered subtree.
  • Independent captures: call html2canvas once per div. This produces a separate canvas for each; combining them is a separate step that requires you to choose their positions and the destination canvas size.

Do not pass an array of IDs or a selector that matches several elements and expect html2canvas to capture all matches. Select one element, or make multiple calls.

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.

Capture several divs together through a wrapper

If you control the markup, put the content to capture inside a common parent and select that parent as the single capture target. This is the simplest way to preserve the divs’ existing arrangement.

<div id="capture">
  <div id="first">First section</div>
  <div id="second">Second section</div>
  <div id="third">Third section</div>
</div>

<script>
async function captureWrapper() {
  const wrapper = document.getElementById('capture');

  if (!wrapper) {
    throw new Error('Could not find #capture');
  }

  const canvas = await html2canvas(wrapper);
  document.body.appendChild(canvas);
  return canvas;
}

captureWrapper().catch(console.error);
</script>

This uses the documented single-element pattern. The example assumes the html2canvas library has already been loaded in the page. The call is asynchronous, so use await inside an async function or attach success and error handlers to the returned Promise.

Keep the wrapper’s contents intentional

A wrapper capture includes the wrapper’s descendant content, not just the divs whose IDs you have in mind. If it also contains a heading, toolbar, unrelated widget, or other visible content, that content may be included too. Put only the desired capture content inside the wrapper, or use separate captures when a suitable wrapper would include material that should not appear.

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.

Use a selected element, not an array of matches

The shorter documented-style selection is:

const canvas = await html2canvas(document.querySelector('#capture'));

querySelector returns one matching element. By contrast, querySelectorAll returns a collection. Passing that collection does not turn a single-element capture call into a multi-element one.

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

Capture unrelated divs separately

When the elements do not share a useful wrapper, look up each ID, discard any missing elements, and call html2canvas for each element. The following example runs the captures concurrently and returns an array of canvases in the same order as the IDs.

async function captureByIds(ids) {
  const elements = ids
    .map(id => document.getElementById(id))
    .filter(Boolean);

  if (elements.length !== ids.length) {
    console.warn('One or more requested IDs were not found.');
  }

  return Promise.all(
    elements.map(element => html2canvas(element))
  );
}

captureByIds(['first', 'second', 'third'])
  .then(canvases => {
    canvases.forEach(canvas => document.body.appendChild(canvas));
  })
  .catch(console.error);

This deliberately returns separate canvases. Appending them to the document displays the individual results; it does not combine them into one image. If every ID must be present for your task to succeed, replace the warning with an error and stop before starting the captures.

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.

Run captures sequentially when needed

Promise.all starts all captures without waiting for earlier ones to finish. If you prefer to process one element at a time, use a loop with await:

async function captureByIdsSequentially(ids) {
  const canvases = [];

  for (const id of ids) {
    const element = document.getElementById(id);
    if (!element) {
      throw new Error(`Could not find #${id}`);
    }
    canvases.push(await html2canvas(element));
  }

  return canvases;
}

Sequential processing is useful when the next operation depends on the previous result or you want failures associated with a specific ID. The available documentation does not establish a performance advantage for either approach; actual time depends on the page and rendered content.

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.

Combine separate canvases into one image

html2canvas does not document a built-in operation that accepts several elements and lays them out in one result. You can compose the separate canvases with the browser’s Canvas API, but you must decide where each one goes. This example stacks the canvases vertically at their native canvas-pixel dimensions:

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
function stackCanvases(canvases) {
  if (canvases.length === 0) {
    throw new Error('There are no canvases to combine.');
  }

  const width = Math.max(...canvases.map(canvas => canvas.width));
  const height = canvases.reduce((sum, canvas) => sum + canvas.height, 0);
  const combined = document.createElement('canvas');
  combined.width = width;
  combined.height = height;

  const context = combined.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 combined;
}

captureByIds(['first', 'second', 'third'])
  .then(canvases => {
    const combined = stackCanvases(canvases);
    document.body.appendChild(combined);
  })
  .catch(console.error);

This stacking arrangement is a practical composition example, not an html2canvas feature. To place canvases side by side, use the maximum canvas height for the destination height, add their widths for the destination width, and advance the x coordinate in drawImage instead of the y coordinate. For a custom grid or gaps, calculate the destination dimensions and each draw position yourself.

The code uses each source canvas’s width and height, so its layout is based on canvas pixels. If you resize, crop, or arrange the results differently, set destination dimensions and draw coordinates to match that intended output. A combined canvas can also be used for later export or display; the example appends it to the document for inspection.

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

Use crop options only to change one capture’s region

The official Examples and Options pages show crop controls using x, y, width, and height. These describe a region for a single capture; they do not make multiple unrelated elements valid as one argument. Similarly, scale and cross-origin resource settings affect rendering or output, not the number of elements accepted by the call.

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

Use a crop when one selected element’s capture region needs to be constrained. Use a wrapper or separate calls when the requirement is to capture multiple DOM elements. Treat these as different problems rather than trying to make crop coordinates stand in for a list of IDs.

What to expect from html2canvas rendering

html2canvas reconstructs a rendering from DOM information and supported browser behavior; it is not a literal capture of the browser’s pixels. Its official About page documents limitations in CSS support and cross-origin resources. As a result, a successful Promise does not guarantee that every style, image, or other resource will appear exactly as it does on screen.

Cross-origin images or canvases can affect whether the resulting canvas remains readable or usable for export. The official Options page describes resource-related configuration, but changing resource settings does not make an unsupported style render correctly or transform a collection of elements into a single target. Check the rendered output with the actual content and resources your page uses.

Troubleshooting multiple-element captures

  • The call errors when given several IDs: select one element or make one call per element. For a combined page-layout capture, pass a wrapper element.
  • Only one div appears: check what your selector returns. querySelector selects one matching element; use a wrapper for descendants or select each ID separately.
  • The wrapper includes unwanted material: the wrapper capture includes content in its subtree. Narrow the wrapper or capture the desired elements independently.
  • A requested ID is missing: getElementById returns no element when that ID is not present. Check that the ID is correct and that the element exists when the code runs; handle missing values instead of passing them to html2canvas.
  • The output has the wrong arrangement: individual canvases do not automatically preserve their original relationship when you compose them. Set the destination canvas dimensions and draw coordinates to match the layout you want, or capture a shared wrapper instead.
  • An image, style, or canvas differs from the page: html2canvas has documented CSS and cross-origin resource limitations and reconstructs the page rather than taking a literal browser-pixel screenshot. Review its About and Options documentation and verify the result with the affected resources.
  • The combined canvas is empty or clipped: confirm the destination canvas has nonzero dimensions large enough for all draw positions. When stacking, its height must accommodate the sum of source heights; when arranging side by side, its width must accommodate their sum.

Or skip the browser setup

If your goal is a screenshot of a publicly reachable webpage rather than a capture of specific live DOM elements or their current JavaScript state, ScreenshotNeo offers a URL-based screenshot API. It does not take a list of div IDs, so it is not a drop-in replacement for the wrapper or composition workflows above.

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

One GET request can return a screenshot or PDF. For example, capture a page as WebP 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 setup and request details. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000 shots. Learn more at ScreenshotNeo, or sign up for the free plan.

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.