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

Use width and height to set the logical canvas area, scale to control output pixel density, and x/y with dimensions to crop a region. For scrollable content, set windowWidth and windowHeight to the element’s scrollWidth and scrollHeight, then check the resulting canvas.width and canvas.height. The complete examples below show predictable dimensions, high-DPI output, cropping and fixes for clipped or blank canvases.

The sizing controls that matter

html2canvas(element, options) reconstructs a page from its DOM and styles; it does not capture the browser’s already-painted pixels. The configuration reference defines these options:

Goal Options What they change
Set the logical capture bounds width, height Canvas area in CSS pixels; defaults to the target element’s dimensions.
Set sharpness or output density scale Bitmap resolution multiplier; defaults to window.devicePixelRatio.
Capture a subsection x, y, width, height Offset and size of the region to render.
Render a complete scroll area windowWidth, windowHeight Virtual rendering window; also influences responsive media queries.
Reproduce a scrolled state scrollX, scrollY Scroll positions used while rendering.

These are different jobs. Increasing scale does not reveal more of a clipped element; it only creates more pixels for the same logical area. Increasing width or height changes the area, while x and y move that area.

Set exact output dimensions

For repeatable output, choose an explicit scale. With scale: 1, the canvas bitmap is approximately one device pixel per CSS pixel. The following example requests a 1,200 by 800 CSS-pixel area and prints the actual bitmap dimensions:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
import html2canvas from "html2canvas";

const element = document.querySelector("#capture");
const canvas = await html2canvas(element, {
  width: 1200,
  height: 800,
  scale: 1
});

console.log({
  cssArea: "1200 × 800",
  bitmapWidth: canvas.width,
  bitmapHeight: canvas.height
});
document.body.appendChild(canvas);

When scale is 2, the same 1,200 by 800 logical area normally produces a bitmap about 2,400 by 1,600 pixels. Use an explicit value when image dimensions must be stable across machines; leaving it unset follows each browser’s window.devicePixelRatio, which is useful for crisp display output but can vary between monitors and sessions.

Fit the element rather than forcing a size

Omit width and height to use the target element’s dimensions. You can inspect those dimensions first:

const rect = element.getBoundingClientRect();
const canvas = await html2canvas(element, {
  width: Math.ceil(rect.width),
  height: Math.ceil(rect.height),
  scale: 1
});

Measure after fonts, images and asynchronous content have loaded; measuring earlier can produce a smaller canvas than the final layout.

Crop a region with x, y, width and height

The official examples use offsets and dimensions to render only a rectangle. Coordinates are relative to the target element:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
const canvas = await html2canvas(element, {
  x: 100,
  y: 100,
  width: 400,
  height: 300,
  scale: 1
});

console.log(canvas.width, canvas.height); // 400, 300 at scale 1

At scale: 2, the logical crop remains 400 by 300 CSS pixels but the bitmap is approximately 800 by 600. Keep the crop inside the element’s rendered bounds. For a user-selected rectangle, clamp the values to zero and to the element’s width and height before calling html2canvas.

Capture a long or wide scrollable element

A scroll container can be clipped because its visible box is smaller than its content. The project FAQ recommends setting the virtual window to the content’s scroll dimensions:

const element = document.querySelector("#capture");
const canvas = await html2canvas(element, {
  windowWidth: element.scrollWidth,
  windowHeight: element.scrollHeight,
  scale: 1
});

This gives html2canvas a rendering window large enough for the scroll area. It can also change media-query evaluation. A page designed for a narrow viewport may reflow when you provide a wide windowWidth, so verify the cloned result and choose dimensions that produce the layout you actually want. If the target is the whole document rather than one scroll container, measure the relevant document or root element and apply the same principle.

Preserve a particular scroll position

Use scrollX and scrollY when fixed or sticky content must be rendered as if the page were at a specific scroll offset:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const canvas = await html2canvas(element, {
  scrollX: 0,
  scrollY: 600,
  width: element.clientWidth,
  height: element.clientHeight,
  scale: 1
});

Test sticky headers and fixed widgets separately; their appearance depends on the virtual scroll state and the cloned DOM.

Wait for content before measuring

Dimensions are only as accurate as the layout at capture time. Wait for fonts and images, then capture:

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
await document.fonts?.ready;
await Promise.all(
  [...document.images].filter(img => !img.complete)
    .map(img => new Promise(resolve => {
      img.addEventListener("load", resolve, { once: true });
      img.addEventListener("error", resolve, { once: true });
    }))
);

const canvas = await html2canvas(document.querySelector("#capture"), {
  scale: 1
});

For content that appears after an API call, wait for the application’s own “ready” signal rather than guessing with a short timeout.

Pixel density, memory and canvas limits

Every increase in area or scale increases the number of bitmap pixels and therefore memory use. The html2canvas FAQ gives approximate current evergreen-browser guidance, not guarantees: Chrome/Chromium and Firefox are around 32,767 pixels for a maximum dimension, with approximate maximum areas of 268 million and 472 million pixels respectively. Desktop Safari is also around 32,767 pixels per dimension; iOS Safari can be lower and depends on device RAM. Limits vary by browser, operating system and hardware; the FAQ points to the canvas-size library for newer test results.

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 a large capture is blank, truncated or throws an allocation error, reduce scale, reduce the capture rectangle, or render several smaller sections and combine them outside the browser. Check both dimensions after rendering:

const maxPixels = 268_000_000; // conservative planning value, not a guarantee
const pixels = requestedWidth * requestedHeight * scale * scale;
if (pixels > maxPixels) {
  throw new Error("Capture is too large; lower scale or split it into tiles");
}

Do not treat that value as a universal browser limit. It is a planning guard; actual limits differ.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Why the result differs from the visible page

The documentation explains that html2canvas “builds the screenshot based on the information available on the page.” Unsupported or incompletely supported CSS can therefore render differently from the browser’s painted result. Correct dimensions cannot fix a property that html2canvas cannot reconstruct.

Cross-origin images and frames

Cross-origin images may be skipped unless the server permits CORS or you provide a suitable proxy. Browser security also prevents reading the document inside a cross-origin iframe. The examples include CORS-related configuration; make sure the image response supplies the required permissions and test with same-origin assets first.

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

Blank or half-rendered output

  • Confirm the selector returns the intended element and that it has non-zero dimensions.
  • Wait for fonts, images and application data before measuring.
  • Lower scale and split very large areas.
  • For clipped scroll content, set windowWidth and windowHeight from scrollWidth and scrollHeight.
  • Check browser security and CORS for external images and iframes.

The FAQ’s wording for this failure is “Why is the produced canvas empty or cuts off half way through?” Its remedies are principally size reduction, correct scroll-window dimensions and checking browser-specific canvas limits.

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

Browser extensions: use a native capture API when appropriate

For extension screenshots, the project FAQ recommends native APIs such as chrome.tabs.captureVisibleTab() and browser.tabs.captureVisibleTab(). They capture the browser’s visible tab rather than reconstructing DOM content and avoid html2canvas’s canvas-size limits. They are a better fit when you need a faithful visible-tab image, while html2canvas remains useful for selecting and rendering DOM regions in ordinary web pages.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. A single request returns PNG, JPEG, WebP or PDF, with options for full-page lazy-image loading, CSS-selector element capture, viewport and device presets, retina scale, custom CSS and JavaScript, waits, request blocking, authentication headers and cookies, geolocation, timezone, resizing, caching and bulk jobs.

Cookie and consent banners, newsletter popups and chat widgets are removed before capture. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

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.
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 documentation for response formats and options. Equivalent clients:

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)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 screenshots each month without a card; paid plans start at $5 for 3,000 shots. Sign up free to try it.

Practical decision checklist

  • Need a predictable bitmap size? Set width, height and an explicit scale.
  • Need sharper output at the same logical size? Increase scale, while watching memory.
  • Need one area only? Add x and y to the crop dimensions.
  • Need all scrollable content? Use scrollWidth/scrollHeight for the virtual window and verify responsive reflow.
  • Need the browser’s actual painted pixels or an extension tab capture? Prefer the native extension API or a remote screenshot service.

Frequently Asked Questions

Does html2canvas resize the source element?

No. Its sizing options control the cloned rendering and output canvas; they do not permanently change your page’s CSS layout.

Why are my canvas dimensions larger than width and height?

A scale greater than 1, including the default device-pixel-ratio scale, multiplies the bitmap dimensions. Inspect canvas.width and canvas.height rather than assuming CSS-pixel values.

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

Can html2canvas capture a cross-origin iframe?

No. Browser security prevents access to a cross-origin iframe document; use same-origin content or a server-side capture approach.

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.