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
Canvas

Why html2canvas Captures Only the Visible Part of a Div—and How to Fix It

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.

If html2canvas captures only the part of a div visible on screen, first give its rendering window the element’s full scroll dimensions. Pass element.scrollWidth as windowWidth and element.scrollHeight as windowHeight. If the missing content belongs to a nested element with its own scrolling, however, expanding the rendering window may not remove that child’s clipping.

Why html2canvas cuts off a div

html2canvas is not a browser-native screenshot tool. It reconstructs a rendering from the DOM and CSS properties it supports. As a result, a capture can differ from what the browser displays, and a larger capture window is not a guarantee that every kind of overflow will be included.

There are two common, distinct cases:

  • The target is larger than the rendering window. The element has more content than the window html2canvas uses to render it, so the output may stop at the visible portion.
  • A child has its own scrollable overflow. The content is clipped inside a nested element with styles such as overflow: auto or overflow: scroll. Increasing the rendering window does not necessarily expand that child’s box or expose its hidden content.

Identify which element is clipping the content before changing options. The first case has a documented window-size adjustment; the second usually requires changing the capture layout or otherwise removing the child’s clipping constraint.

First fix: size the rendering window to the target

For an ordinary element that is being truncated by a viewport-sized rendering window, try the approach in the html2canvas FAQ:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const element = document.querySelector("#capture");

if (!element) {
  throw new Error("Could not find #capture");
}

const canvas = await html2canvas(element, {
  windowWidth: element.scrollWidth,
  windowHeight: element.scrollHeight,
});

document.body.appendChild(canvas);

This example assumes html2canvas is loaded and called in a browser context. Measure the same element you pass to html2canvas. scrollWidth reflects the element’s full horizontal content area; scrollHeight reflects its full vertical content area. Using an unrelated wrapper’s dimensions can leave the actual target clipped.

The output canvas dimensions and the rendering window dimensions are separate settings. According to the configuration reference, windowWidth and windowHeight define the window dimensions used for rendering; width and height set the output canvas dimensions. Adjust the latter when the output canvas itself is constrained, but do not expect canvas dimensions alone to reveal content clipped inside a nested scroll container.

Handle a separately scrollable child

Suppose #capture contains a panel with a fixed height and overflow-y: auto. The panel may display only its current scroll position, even when the outer target’s scroll dimensions are larger. An html2canvas issue report documents a scrollable-child case in which changing window and scroll options did not expose all content. It does not establish a universal option combination that fixes every such layout.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Use a capture-only layout when appropriate

If the desired image should show the entire child, create a capture state that removes or relaxes the clipping constraint, then render and restore the normal styles. For example, a class can make the child’s height automatic and its overflow visible:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const target = document.querySelector("#capture");
if (!target) throw new Error("Could not find #capture");

target.classList.add("capture-all-content");

try {
  const canvas = await html2canvas(target, {
    windowWidth: target.scrollWidth,
    windowHeight: target.scrollHeight,
  });
  document.body.appendChild(canvas);
} finally {
  target.classList.remove("capture-all-content");
}
/* Apply to the nested element that actually clips the content. */
#capture .scroll-panel.capture-expanded {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

In practice, add the class to the clipping child (or use a selector scoped to the capture state), and ensure the CSS is active before calling html2canvas. The sample’s class placement is illustrative: the exact selector depends on your DOM. Check whether expanding the child changes the layout, widths, sticky elements, or neighboring content; a capture layout can differ from the interactive page by design. Remove temporary classes in a finally block so an error does not leave the page in its expanded state.

Check the dimensions and layout in this order

  1. Measure the captured element. Inspect scrollWidth, scrollHeight, clientWidth, and clientHeight on the exact node passed to html2canvas. A scroll dimension larger than the client dimension indicates overflow to investigate.
  2. Find the clipping ancestor. Inspect the target and its descendants for fixed heights, max-height, and overflow rules. The element passed to html2canvas may not be the element imposing the clip.
  3. Set window dimensions for viewport truncation. Use the target’s scroll dimensions as shown above when the target’s full content is laid out but the rendering window is too small.
  4. Inspect output dimensions separately. If configured width or height limits the canvas, correct those values or remove them for a diagnostic capture. They are not substitutes for addressing nested overflow.
  5. Check responsive rules. Changing windowWidth or windowHeight can affect media queries. The expanded render may select different CSS breakpoints and produce a different layout from the on-screen view.
  6. Check for canvas limits and unsupported content. A partial or blank result can have causes other than clipping; see the sections below.

Keep the capture within browser canvas limits

Very large canvases may render only partly or appear blank. The html2canvas FAQ gives rough browser guidance, observed on its current page in 2026. These are not stable specifications or guarantees for a particular device:

Browser Rough limits cited by the html2canvas FAQ
Chrome / Chromium About 32,767 px maximum dimension and about 268 million pixels maximum area
Firefox About 32,767 px maximum dimension and about 472 million pixels maximum area
Desktop Safari About 32,767 px maximum dimension; area described as similar to Chrome
Safari on iOS Lower maximum, depending on device RAM

Actual limits vary by browser, operating system, and device. The FAQ links to a canvas-size library for current tests; do not treat the figures above as a promise that a capture at those dimensions will work. If the content is exceptionally tall, consider capturing sections separately and composing them, or reducing output scale if your design allows it. The configuration reference documents scale; lowering it reduces the canvas pixel dimensions, with a corresponding reduction in output detail.

When changing dimensions will not fix missing content

Unsupported CSS

html2canvas implements CSS properties individually and does not support all CSS. Its FAQ puts it directly: “Every CSS property must be manually implemented to render correctly, so html2canvas will never have full CSS support.” If dimensions are correct but a style or element still looks wrong, check the project’s supported-feature guidance rather than assuming the canvas is clipped.

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

Cross-origin images

Images served from another origin need appropriate CORS permission or a same-origin proxy. The useCORS: true option can request images through CORS, but it cannot make a remote server grant permission. If the server does not send suitable CORS headers, use an image source you control or a proxy configured to serve it safely.

Browser extension captures

If the goal is to capture an entire browser tab from an extension rather than render a specific DOM node, the html2canvas FAQ recommends using browser capture APIs for that setting. A DOM-rendering library and an extension’s tab-capture API solve different problems.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Troubleshooting symptoms and fixes

Symptom Likely cause What to try
Output ends at roughly the visible portion of the target Rendering window is too small for a normally laid-out target Set windowWidth and windowHeight from the target’s scroll dimensions.
Only part of a nested panel appears A child’s own overflow or fixed height clips content Inspect the child and its ancestors; test a capture-only layout that removes the clipping.
Capture layout differs from the page New window dimensions triggered different media queries Check responsive breakpoints and decide which viewport layout the image should represent.
Canvas is blank or partly rendered Canvas exceeds platform limits, or another rendering issue is present Reduce dimensions or scale, split a very large capture, and check unsupported CSS and image access.
Images are missing Cross-origin server does not grant CORS access, or another image-loading issue exists Try useCORS: true only when the server permits it; otherwise use a suitable same-origin source or proxy.
Setting width and height changes the output but not the missing child content Canvas dimensions were changed, but nested overflow remains Address the child’s layout and clipping separately.

Performance and reliability considerations

Rendering a large DOM region into a canvas takes more work than rendering a small one, and larger pixel dimensions consume more memory. Capture only the content you need, avoid unnecessarily large scale or window dimensions, and be cautious with full-page or very tall elements on memory-constrained devices. If a single canvas approaches platform limits, splitting the content is safer than assuming a larger configured window will succeed.

For repeatable output, make the page’s state explicit before capture: wait until the target is present, ensure images have loaded, and apply any temporary capture styles before calling html2canvas. Restore those styles afterward. These steps address page readiness and layout changes; they do not add support for CSS properties html2canvas cannot render or bypass browser CORS restrictions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 the goal is a website screenshot rather than rendering a particular local DOM node, ScreenshotNeo is a website screenshot API and MCP server for developers. Its API returns PNG, JPEG, WebP, or PDF from a URL. For example, this cURL request saves a WebP capture of the target site. See the ScreenshotNeo API documentation for parameters and response details.

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://stripe.com 
  -o shot.webp

Unlike html2canvas, this captures a URL in a browser service rather than a specific DOM node in your current page, so it is not a direct fix for every nested-div use case. ScreenshotNeo removes cookie/consent banners, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, failed loads, and cache hits are not billed, with response headers indicating the page verdict and billing status. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month without a card.

Frequently Asked Questions

Do I need to set both window dimensions?

For a target that is clipped by a viewport-sized rendering window, set both from the target’s scroll dimensions. If only one direction is overflowing, inspect that axis and the element’s layout as well.

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

Will windowWidth and windowHeight preserve the page’s on-screen layout?

Not necessarily. Those dimensions can affect media queries, so the render may use different responsive styling.

Does useCORS: true make every remote image appear?

No. The image server must grant cross-origin access, or you need a suitable same-origin proxy.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.