Hiding elements

Hide an element without the page collapsing around it

Removing a node changes the layout. Hiding it keeps the space — which is why a hidden capture still looks like the page a visitor sees.

hide_selectorserror_on_selector_not_foundstyles
curl --fail-with-body "https://api.pagecapture.dev/v1/take" \
  -H "X-Access-Key: $PAGECAPTURE_KEY" \
  -H "Content-Type: application/json" \
  --data '{"url":"https://example.com","format":"jpg","hide_selectors":"header"}' \
  -o capture.jpg

Verified 2026-08-13 by running the published code against a fixture.

Configure it in the playground
What you are seeing

You need the page without one part of it — a support bubble, a promo bar, a personal name in a demo — and deleting the node reflows everything below it.

Why the page does that

`display: none` takes the element out of flow. Everything after it moves up, and the screenshot stops matching the page it is supposed to document.

What it does

  • Applies `visibility: hidden !important` to every selector you pass, in one injected rule, before scripts and actions run.
  • Skips a selector that matches nothing. The capture continues, because a missing element is usually a page variant rather than a failure.
  • Composes with the built-in blockers: chat and consent selectors join the same hidden set when those flags are on.

What it does not do

  • Does not reflow the page. The element keeps its box; only its pixels go.
  • Does not reach inside a closed shadow root by default. `include_shadow_dom` is what makes selectors cross that boundary.
  • Does not remove anything from the DOM, so a script that measures the element still finds it.
The contract

Every limit on this page is the one the API enforces

These rows are read from the same parameter table that validates your request. Nothing here is transcribed, so a number cannot drift from the behaviour it describes.

ParameterTypeDefaultRangeEndpointsCache key
hide_selectors

Selectors to hide before capturing.

string[]/v1/take, /v1/animateIn
error_on_selector_not_found

Fail when the capture, hide or wait selector does not match, instead of skipping it.

booleanfalse/v1/take, /v1/animateIn
styles

CSS injected into the page.

string[]/v1/take, /v1/animateIn
Group: Page customizationValues outside a documented range are rejected before a browser opens.

How it behaves next to the rest of the request

error_on_selector_not_found

Fail when the capture, hide or wait selector does not match, instead of skipping it.

Default `false`, and the asymmetry is deliberate: a capture selector that matches nothing is skipped, while a `click` or `hover` selector that matches nothing fails. Set it to `true` when a missing element means the page is wrong, not just different.

include_shadow_dom

Traverse open shadow roots when resolving selectors and serializing HTML.

Widgets shipped as web components live in shadow roots. Without this flag the selector never matches, and — with the default failure policy — you get a clean capture that quietly still contains the widget.

styles

CSS injected into the page.

If you need the space to collapse after all, inject `display: none` through `styles` instead. Hiding is the safe default; removal is the explicit choice.

Errors this option can produce

None of them is billable. No error code in the catalog is.

Questions this raises

What happens if my selector matches nothing?

Nothing is hidden and the capture succeeds. Set `error_on_selector_not_found=true` to turn that into `selector_not_found` instead — and remember that a failed capture is never billed.

Why visibility instead of display?

Because the point of a screenshot is usually to look like the page. Collapsing the layout changes what everything below the hidden element looks like, which is a bigger edit than the one you asked for.

Can I hide several things at once?

Yes — the parameter takes a list, and every entry lands in the same injected rule.