The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Empty space above an html2canvas image has two fundamentally different causes: the target element really contains top margin or padding, or the renderer is using a scroll/crop coordinate that does not match the pixels you intend to capture. Inspect the element first. If the gap is part of its layout, fix that CSS (or override it only in onclone). If the element is correct but the bitmap includes unwanted pixels, adjust the crop with y and height. Use scrollY only to align rendering with the intended scroll position.
Start by identifying which kind of space you have
Do not begin by guessing at canvas dimensions. Render the target page normally, then inspect the exact element passed to html2canvas. The following test records the box and the styles most likely to create a real gap:
const target = document.querySelector('#capture-target');
const rect = target.getBoundingClientRect();
const style = getComputedStyle(target);
console.table({
top: rect.top,
height: rect.height,
marginTop: style.marginTop,
paddingTop: style.paddingTop,
transform: style.transform,
position: style.position,
overflow: style.overflow
});
- If
marginToporpaddingTopexplains the pixels, the whitespace is genuine layout. Fix the responsible rule, or apply a narrowly scoped clone-only override. - If those values are expected but the output still starts too low, compare captures at the top of the document and at the current scroll position. A fixed or sticky descendant, document scroll state, or crop origin may be involved.
- If the element renders correctly and only the bitmap contains extra rows, crop the canvas. Cropping hides pixels; it does not repair layout.
Keep a minimal reproduction while diagnosing. The historical reports associated with this symptom used html2canvas 1.0.0-rc.3 with Chrome 74 or 75 on Windows 10. They demonstrate that users saw scroll-related offsets, but they do not establish a current, universal defect or a single fix for every release.
Fix a real margin or padding gap
Correct the source CSS when the spacing is intentional to remove
Use the browser inspector to walk from the target element through its parents. Check collapsing margins, flex or grid alignment, transforms, and an ancestor that contributes padding. Remove or change only the rule responsible for the unwanted space:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
- 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
- Optical Zoom: 4x optical zoom with a 27mm wide angle lens for flexible framing indoors or outdoors
- Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
- Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
- LCD Screen and Battery: 2.7in LCD screen with 2 AA alkaline batteries for convenient on-the-go use
#capture-target {
margin-top: 0;
padding-top: 0;
}
Do this in the page stylesheet when the layout itself should change. If the live page must retain its design, use a clone-only change instead.
Override the cloned document with onclone
onclone runs after html2canvas creates its rendering clone. A targeted edit changes the capture without mutating the visible page or other components:
const element = document.querySelector('#capture-target');
html2canvas(element, {
onclone(clonedDocument) {
const clone = clonedDocument.querySelector('#capture-target');
if (clone) {
clone.style.marginTop = '0';
// Set paddingTop to 0 only if your inspection found that cause.
// clone.style.paddingTop = '0';
}
}
}).then(canvas => {
document.body.appendChild(canvas);
});
Replace the selector and property with the actual cause. Avoid a global reset such as removing every margin in the clone: headings, cards, and nested content may rely on those values, and the result can become less accurate than the original.
Rank #2
- 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
- Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
- Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
- Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
- LCD Screen and Battery: 2.7in LCD screen and a rechargeable lithium-ion battery for on-the-go use
Separate scroll position from crop coordinates
The html2canvas options involved here operate in different coordinate spaces:
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match| Option | What it controls | Use it when |
|---|---|---|
y |
The y-coordinate at which the canvas crop begins | The rendered content is correct, but you want to omit rows at the top of the output |
height |
The output canvas height | You know exactly how many vertical pixels should remain |
scrollY |
The scroll position used while rendering the element | You need fixed or sticky content rendered as it would appear at a particular document scroll position |
windowHeight |
The rendering viewport height, which can affect media queries | The capture must use a particular responsive breakpoint; it is not a top-margin-removal switch |
Changing all of these at once makes the diagnosis harder. Establish whether the wrong pixels come from layout, scroll state, or the crop, then change the smallest relevant setting.
Test the same element at two scroll positions
Capture once from the top and once from the current position. Restore the user’s position afterward:
Rank #3
- Latest Digital Camera Built-in Fill Light : This compact digital camera is paired with a powerful CMOS processor and image stabilization to help you take & record the most exciting moments in 44 MP quality images & FHD 1080P quality videos anywhere, anytime. Plus, there is also a built-in fill light to help you take high quality pictures even in low light&dark settings, making this the perfect camera for all indoors/outdoors situations.
- Long-Lasting Battery Life & 16X Digital Zoom :This point and shoot camera will retain its battery charge even after long use. The controls and functions are easy to operate making this the perfect choice for children, teens and younger. This kids camera supports 16x digital zoom, you can zoom in or out the subject by pressing the W/T button for taking still photos to zoom in or out on distant objects and capture all the details you need.
- Multifunctional & Portable Digital Camera: This cheap digital camera is slim enough to fit in your pocket. You'll easily be able to take it with you on all your indoor/outdoor activities and adventures and ideal for beginners, children and teenagers. This kids digital camera is equipped with 20 filters, anti-shaking, self-timer, continuous shooting, date stamp, time-lapse recording, smile capture, internal MIC and speaker (recording sound videos), great for your daily photography needs.
- WEBCAM & PAUSE FUNCTION : More than just a FHD 1080p digital camera, it also works as a webcam for video calls and vlogging. Connect the camera to the computer, press shutter and power button at the same time and the camera will automatically turn on webcam mode for all your video calling and live streaming needs. The pause function allows you to pause when seeing playback videos.
- A Must Have Photography Device : This digital camera with SD card made from high-quality materials, this retro camera is safe and durable. Perfect for all ages to develop & improve their photographic abilities and observation skills. Our dedicated and experienced 24/7 support team is available for all after purchase troubleshooting, questions and technical help.
const element = document.querySelector('#capture-target');
const originalY = window.scrollY;
window.scrollTo(0, 0);
const atTop = await html2canvas(element);
window.scrollTo(0, originalY);
const atCurrentPosition = await html2canvas(element);
// Compare atTop and atCurrentPosition, then restore the page exactly.
window.scrollTo(0, originalY);
If the extra area changes with scrolling, investigate fixed or sticky descendants and the rendering scroll position before touching CSS. A historical report said that scrolling to (0, 0) removed a large offset in html2canvas 1.0.0-rc.3; that observation is version- and environment-specific, so treat it as a diagnostic experiment rather than a blanket remedy.
Crop pixels only after the content is correct
When inspection shows that the target is laid out correctly and the unwanted rows are purely an output choice, set a crop origin and output height. This illustrative pattern uses the target’s measured height:
const element = document.querySelector('#capture-target');
const rect = element.getBoundingClientRect();
const canvas = await html2canvas(element, {
y: 0, // crop origin in the rendered canvas
height: rect.height, // desired output height
scrollY: -window.scrollY // test only when matching viewport position is intended
});
document.querySelector('#preview').replaceChildren(canvas);
This is not a universal recipe. The correct values depend on whether you pass an element or capture a viewport, the current scroll position, and whether the desired output preserves fixed elements. For a viewport screenshot, the element’s rectangle may not be the right height at all. Measure the intended capture area and verify the first and last content rows visually.
A repeatable troubleshooting procedure
- Record the environment. Note the installed html2canvas version, browser, operating system, target selector, and whether the page is scrolled. Historical issue reports alone cannot predict current behavior.
- Inspect the rendered box. Compare
getBoundingClientRect()with computed margin, padding, transform, position, and parent layout. - Disable capture changes. Remove custom
x,y,scrollX,scrollY, viewport dimensions, and output resizing. Establish a plain baseline. - Compare scroll states. Capture at
scrollY = 0and at the normal position. Note changes in fixed and sticky descendants. - Apply one correction. Fix the identified CSS, use a targeted
onclonerule, or set crop coordinates—never all three as a first attempt. - Retest a minimal page. Reduce the case to one target, one stylesheet, and the smallest set of options. This distinguishes your page’s layout from a library or browser interaction.
Common symptoms, causes, and fixes
| Symptom | Likely explanation | Action |
|---|---|---|
| Space is present in the DOM and in the normal page | Margin, padding, parent layout, or transform | Correct that rule, or override only the affected clone node with onclone |
| Space changes after scrolling | Rendering scroll state or fixed/sticky content | Compare top/current captures and test an explicit scrollY; preserve the intended viewport behavior |
| Top content is correct but output has extra blank rows | Crop origin or output height does not match the desired bitmap | Set y and height after measuring the intended region |
Changing windowHeight changes the gap |
A media query or responsive layout changed | Use the viewport size required by the design; do not treat it as a margin fix |
| Increasing viewport dimensions improves one case but offsets remain | Viewport and scroll coordinates are interacting with a different capture mode | Reproduce the same mode, remove unrelated options, and derive coordinates from the actual target |
| The fix works in an old reproduction but not now | Browser or html2canvas version difference | Retest the installed release and keep the version in your bug report |
Performance and reliability considerations
- Large, full-page captures require more memory than a small element capture. Start with the smallest target that answers your use case.
- Lazy-loaded images, web fonts, animations, and asynchronous layout can move the measured box between inspection and capture. Wait for the page’s own ready state and use a stable reproduction before adjusting coordinates.
- Fixed and sticky elements are sensitive to the rendering viewport and scroll position. Decide whether they should appear once, remain pinned, or be excluded, then test that behavior explicitly.
- Do not silently crop a genuine design gap if the image is intended to document the page exactly. Cropping is appropriate when the output specification—not the page layout—requires fewer pixels.
- Keep the original scroll position when running diagnostics in an interactive page. Users should not be left at the top simply because a capture was attempted.
Or skip the browser setup
For server-side or repeatable website screenshots, ScreenshotNeo accepts one GET request and returns PNG, JPEG, WebP, or PDF. It handles the page visit rather than asking you to manage a browser process:
Rank #4
- 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
- Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
- Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
- Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
- LCD Screen and Battery: 2.7in LCD screen and a rechargeable lithium-ion battery for on-the-go use
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const buffer = Buffer.from(await res.arrayBuffer());
// Save buffer to shot.webp with your preferred filesystem API.
See the ScreenshotNeo documentation for request parameters. Before capture it can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, 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.
The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is included on every plan. If you want clean output without maintaining browser setup, create a free ScreenshotNeo account.
When to choose each fix
| Your observation | Best first move |
|---|---|
| The page itself has unwanted top spacing | Fix the source CSS |
| The page must stay unchanged, but the capture should not include that spacing | Apply a targeted onclone override |
| The element is correct, but the bitmap starts too high or low | Investigate scroll state, then set y/height for the intended crop |
| You need automated screenshots without a browser in your application | Use ScreenshotNeo’s API or MCP server |
Frequently Asked Questions
Does setting height remove a margin from the page?
No. It changes the canvas output height. A real margin or padding remains in the rendered layout unless you change CSS or use a targeted onclone override.
Should I always set scrollY: -window.scrollY?
No. That value is appropriate only for a capture whose coordinate system is intended to match the current viewport. Test top and current scroll states first, especially when fixed or sticky elements are present.
Is the old whitespace issue proof that html2canvas is currently broken?
No. The cited reports are historical, version-specific observations from Chrome 74/75 on Windows 10 and do not establish a current general bug.
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.

