What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
To capture an HTML element at a fixed width with html2canvas, set the element’s CSS width to the layout width you want, set windowWidth if responsive styles should behave as though the page has that viewport width, and set scale deliberately if the output pixel dimensions must be predictable. The width option sets the canvas width; it does not, by itself, make the element reflow to that width.
Which width do you need to control?
“Fixed width” can mean two different things: the width at which the browser lays out the target, or the width of the resulting canvas. Those are related, but they are not interchangeable. html2canvas reconstructs an image from DOM information; it does not take a native screenshot of the browser’s rendered pixels, and it does not support every CSS property. See the project’s documentation on how html2canvas works and its limitations.
| What you want | Set this | What it controls |
|---|---|---|
| A component laid out at a particular CSS width | The target element’s CSS width |
The element’s layout. Responsive child styles and wrapping respond to this layout width. |
| The page’s responsive styles to behave as if the viewport has a particular width | windowWidth |
The virtual window width used while rendering; it can affect media queries. Its default is Window.innerWidth. |
| A canvas with a particular width | width |
The output canvas width. Its default is the element width. |
| More raster pixels for the same CSS-sized layout | scale |
The rendering scale. Its default is window.devicePixelRatio. |
The option definitions and defaults are in the project’s configuration reference. When exact pixel dimensions matter, set both the intended CSS layout width and an explicit scale, then inspect canvas.width. A scale above 1 produces more pixels for a given CSS size; for example, an 800 CSS-pixel-wide result rendered at scale 2 is generally 1,600 canvas pixels wide.
Choose the right setup for your capture
One element should have a fixed layout width
Set the target element’s CSS width to the desired value. If the element’s internal layout should respond to a viewport of the same width, set windowWidth to that value too. Use width when you also want to specify the canvas width explicitly. This is a common choice for a card, chart, report, or other component that should wrap consistently.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problems#1 Best Overall
The whole page should reflow at a breakpoint
Set windowWidth to the viewport width that activates the intended responsive styles. Setting only the canvas width does not make media queries run as if the browser window had that width. For this case, check the page’s layout at the chosen breakpoint and confirm that the element itself has the expected CSS width as well.
You need a fixed output size, not a new layout
Specify the canvas dimensions and scale, but remember that an output-size setting does not substitute for controlling layout. If the source element is laid out wider or narrower than intended, the image can still have unwanted wrapping, clipping, or content placement. Verify the rendered result rather than relying on the requested width alone.
Capture an element at 800 CSS pixels wide
Make sure html2canvas is loaded in your page or imported into your application, as described in the project’s Getting Started guide. Then capture the element after the page content is ready. This example saves and restores any inline width already on the element, so the temporary capture layout does not remain applied afterward.
Rank #2
async function captureFixedWidth() {
const element = document.querySelector("#capture");
if (!element) throw new Error("Could not find #capture");
const targetWidth = 800;
const previousWidth = element.style.width;
element.style.width = `${targetWidth}px`;
try {
const canvas = await html2canvas(element, {
windowWidth: targetWidth,
width: targetWidth,
scale: 1,
});
console.log(`Canvas width: ${canvas.width}px`);
return canvas;
} finally {
element.style.width = previousWidth;
}
}
const canvas = await captureFixedWidth();
Here the element’s CSS width controls its layout, windowWidth makes the virtual viewport 800 CSS pixels wide, width requests an 800-pixel canvas width, and scale: 1 avoids multiplying the output dimensions by the device pixel ratio. If you do not want responsive page styles to change, choose windowWidth based on the desired page viewport instead of automatically matching the component width.
Free tools Windows power users keep installed
One-click scans. No signup required.
The example changes the live element briefly. If modifying the visible page is undesirable, use the library’s supported customization mechanisms to apply the capture-specific styling to the cloned document instead. The project examples show x, y, width, and height used to capture a specific region; consult the official examples when you need a crop rather than a different layout width.
Capture content beyond the visible viewport
A capture can be cut off if the target extends beyond the virtual window dimensions. For content that should include the element’s full scrollable extent, the project FAQ recommends setting the virtual dimensions from its scroll dimensions:
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,
scale: 1,
});
This is guidance for capturing content beyond the current viewport, not a rule that every fixed-width capture should use element.scrollWidth. If the requested layout width is 800 pixels but the element’s scroll width is larger, using the scroll width changes the virtual window to that larger value. Choose dimensions for the layout you actually want. The project’s FAQ gives approximate browser canvas limits: around 32,767 pixels per dimension for Chrome/Chromium and Firefox, and around 268 million pixels of area for Chrome/Chromium and 472 million for Firefox. It also lists around 32,767 pixels per dimension for desktop Safari, with lower iOS limits depending on device RAM. These are approximate, browser- and platform-dependent limits, not guarantees.
Export the result as an image
For a small capture, the project examples demonstrate making a PNG data URL and triggering a download:
const link = document.createElement("a");
link.download = "capture.png";
link.href = canvas.toDataURL("image/png");
link.click();
For a larger image, consider canvas.toBlob() where it suits your workflow, rather than creating a large base64 data URL. Either way, choose the MIME type and filename to match the format you need, and verify the downloaded image’s dimensions.
Rank #4
Troubleshoot the usual width and rendering problems
The layout is still responsive at the wrong width
- Set the target element’s CSS width if its own layout needs to change.
- Set
windowWidthif media queries should respond to a particular virtual viewport. - Use
widthonly for the canvas width; it does not independently force responsive reflow. - Check the computed layout and the returned
canvas.widthseparately.
A remote image is missing
Browser security rules govern whether html2canvas can read cross-origin resources. The project documentation recommends trying useCORS: true when the remote server sends a suitable CORS header, or using a proxy that retrieves the resource in a permitted way. useCORS attempts a CORS-enabled load; it does not override the remote server’s policy. See the FAQ and examples.
An iframe is missing
The documentation says same-origin iframe content is supported recursively. Cross-origin iframe content cannot be rendered because browser security rules make its document inaccessible to the page. This is a security boundary, not a width-setting problem. The limitation is described in the project documentation.
The image is blank, truncated, or unexpectedly large
- Check the target’s
scrollWidthandscrollHeight, and compare them with your chosen virtual window and canvas dimensions. - Confirm that the chosen
scaleis intentional; a larger scale increases the raster dimensions. - For content beyond the visible viewport, select virtual dimensions that include the desired content without accidentally making the layout wider than intended.
- If the capture approaches browser canvas limits, reduce its dimensions or split long content into sections. Limits vary by browser and device.
The result does not look exactly like the browser
html2canvas reconstructs the image from DOM information and the CSS properties it understands rather than copying the browser’s native rendered pixels. Unsupported or partially supported CSS can therefore look different. If a particular effect is absent or altered, check the project’s documentation for CSS support and limitations before treating a width adjustment as the fix.
Best Value
Performance and reliability considerations
Large canvases consume more browser resources than small ones, especially when both dimensions or the render scale increase. Keep the capture to the necessary area, choose an explicit scale when pixel size matters, and avoid using full scroll dimensions when the desired output is only a fixed-width viewport or component. A browser’s maximum canvas dimensions are not a promise that every device can create a canvas at that size.
For repeatable captures, wait until the target content is present before calling html2canvas, preserve or restore any temporary inline styles, and check both the visual output and its actual canvas dimensions. Treat missing cross-origin images, inaccessible iframes, and unsupported CSS as separate causes: changing width will not bypass browser security or add CSS support.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. A single GET request takes a URL and returns a PNG, JPEG, WebP, or PDF. It is an alternative when you need a rendered website capture without building a browser-side html2canvas flow; it is not a way to capture an arbitrary in-page DOM element using html2canvas options.
For a URL screenshot, the cURL request below saves a WebP file. See the ScreenshotNeo API documentation for request options.
Recommended Free Tools
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Equivalent Python request:
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)
Equivalent Node.js request:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
- Before the shot, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing; response headers report the page verdict and whether the request was billed.
- Its MCP server offers
take_screenshot,get_page_info, andcapture_pdffor AI agents, including 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. All features are on every plan, and yearly billing gives two months free.
Sign up for 1,000 free screenshots a month with no card.
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.




