skip to content

html, css, and dom · lesson 3 of 8 · sources checked 2026-11-20

render and visibility: hidden text, honeypots, and decoys

This lesson shows how to decide if a human can see an element, and which hidden elements a site uses to catch automation.

status of this lesson: from a public source

purpose

A human sees the computed style and the layout of a page, not its markup. Thus a collector can keep text that no human sees, or touch an element that no human touches. A site puts such elements in a page to catch automation, for example a honeypot element.

objectives

  1. Decide if an element is visible with the computed style and the bounding box.
  2. Name the decoy element and honeypot element patterns of the DOM, and the signal of each one.
  3. Explain why a render alone does not remove all hidden text.
  4. Apply a visibility check as a safety check of a collector.

new terms

computed style
The final style values of an element after the browser applies all CSS rules.
honeypot element
An element that a human cannot see or reach, put in a page to catch automation.
signal
One observed value that a detector uses as evidence.
crawler trap
A link structure or hidden link that leads a crawler into an endless or a flagged path.
decoy element
A hidden element with an event listener that catches a client which selects elements from the DOM.
DOM-enumerating agent
An agent that reads the document tree to select its targets.
pixel-only agent
An agent that selects targets from a screen image only.
CAPTCHA
A challenge that a human can pass and a program cannot pass easily.
honeysite
A site that nobody advertises, so that all its traffic is automated.
AI crawler
A crawler that collects content for model training, AI search, or a fetch that a user starts.
detection side
The people and products that protect a site against unwanted automation.

how it works

The browser applies all CSS rules to each element. The method getComputedStyle() gives the resolved values of all CSS properties of an element, after the browser applies the active style sheets MDN, source 1. The method getBoundingClientRect() gives the position and the size of its box.

the visibility decision

A human cannot see an element when one of these conditions is true:

  1. display is none.
  2. visibility is hidden or collapse.
  3. opacity is near 0.
  4. The width or the height of the box is less than 1 px.
  5. The box is outside the page, for example at left: -10000px.
  6. The text color is the same as the background color.

A regex extractor sees none of these conditions, because it reads only the markup.

When you render a page in a browser, its visible text leaves out the elements with display: none or visibility: hidden. But a text with opacity: 0, a box outside the page, or white text on white stays in it. Thus a render alone does not remove all hidden text. The extractor must also apply the visibility check.

patterns that catch automation

A site can put these patterns in the DOM. Each pattern gives the site a signal when a client touches it:

patternwhat the page holdssignal for the site
Honeypot elementA form field that a human cannot see, for example an input with display: noneA value in that field when the form arrives
Hidden linkA link with no visible box, for example a crawler trapA request to the path of the link
decoy elementA created button with a fixed position, opacity: 0, and a click listenerA click event on the decoy
Hidden textText that CSS hidesThe text in a copy of the data

A human never touches a honeypot element or a decoy element. Thus a fill or a click is a strong signal of automation.

decoys and the two kinds of agents

A decoy element catches a client that selects elements from the DOM. A DOM-enumerating agent reads the document tree to select the elements that it acts on. For example, it can find the decoy in a list of all buttons and click it.

A pixel-only agent selects the elements that it acts on from a screen image only. A transparent decoy draws no pixels, so the agent cannot select it from the image.

But a decoy with a fixed position can cover the page, and a click at a screen position can land on it. Thus it is not known which of the two kinds of agents a transparent decoy catches. This course has no measurement of it.

public forms of these traps

claim of a publisher In 2021, a W3C note stated that a CAPTCHA that robots see and humans do not see appears to be successful enough W3C, source 2. The note also said that this method is available in more than one content management system. It said that the method is easy to add to a page.

A trap can also be a full site. In 2021, a study used 100 sites that existed only to attract and record bot traffic, as a honeysite does NSF PAR, source 3. In seven months, the sites recorded 26.4 million requests.

claim of a company Cloudflare states that its AI Labyrinth links a suspected AI crawler to generated pages Cloudflare, source 4. The company states that the links stay invisible to human visitors. It also states that a visitor four links deep into the pages is very likely a bot.

a static detector rule

A static rule can find the decoy pattern in the script of a page. It looks for one function that does all four of these steps:

  • It creates an element.
  • It sets a fixed or absolute position.
  • It sets a style that is transparent, hidden, or outside the screen, for example opacity: 0.
  • It adds a click listener.

The lesson Traps, honeysites, and decoy content (not yet published) teaches the design of traps on the detection side.

the two sides

automation sidedetection side
A visibility check stops the collector before it clicks a trap or fills a hidden field. A pixel-only agent does not see a transparent decoy. A DOM-enumerating agent does.A honeypot element or a decoy element costs the site almost nothing. A human never touches it. A click or a fill is a strong signal of automation.

design decisions

optiongaincostwhen it is correct
Regex extraction with no visibility checkThe lowest cost for each pageHidden text goes into the dataFeeds and pages with no hidden text
A render with no visibility checkElements with display: none or visibility: hidden go outText with opacity: 0, a box outside the page, or a same-color text staysPages with client-side content and no traps
A render and the visibility checkThe text that a human seesMore time for each elementEach page where the data must equal the visible page
The visibility check before each click or fillThe collector does not touch a trapThe check cannot find each trapEach collector that clicks or fills a form

diagram

the visibility decision for one element, from the computed style and the bounding box

One true condition is sufficient to mark the element as hidden.source: My model of the visibility decision

the decoy pattern: a page script makes a transparent decoy and reports a click on it

The page script reports the click on the decoy to the site backend.source: My model of the decoy pattern

A table of three extraction methods and four things they can see. A regex sees the markup only. A DOM parse with no render sees the markup and the tree. A render in a browser sees the markup, the tree after scripts, the computed style, and the layout.

what each extraction method can see
methodmarkuptreecomputed stylelayout
Regex on the response textyesnonono
DOM parse with no renderyesyesnono
Render in a browseryesyes, after scriptsyesyes
Each method can see a different part of the page.source: My model of what each extraction method can see

code example

The example applies the six checks to the stored style values of each element. In a browser, the function readStyle gets the values from getComputedStyle() and getBoundingClientRect().

example The stored values are synthetic. In this Node example, the function readStyle does not run.

m05-x06-visible.tstypescript

Decide for each element if a human can see it, from the computed style and the bounding box. Flag each hidden element that the collector must not touch.

import { readFileSync } from "node:fs";

// The values that getComputedStyle(el) and el.getBoundingClientRect() give in a browser.
type Style = {
  display: string; visibility: string; opacity: string; color: string; background: string;
  left: number; top: number; width: number; height: number;
};

// In a browser page at scroll position 0, this function reads the style values of one element.
// It does not run in this Node example.
function readStyle(el: any, bg: string): Style {
  const s = getComputedStyle(el);
  const r = el.getBoundingClientRect();
  return { display: s.display, visibility: s.visibility, opacity: s.opacity, color: s.color,
    background: bg, left: r.left, top: r.top, width: r.width, height: r.height };
}

function hiddenReasons(s: Style): string[] {
  const why: string[] = [];
  if (s.display === "none") why.push("display none");
  if (s.visibility === "hidden" || s.visibility === "collapse") why.push(`visibility ${s.visibility}`);
  if (parseFloat(s.opacity) < 0.05) why.push(`opacity ${s.opacity}`);
  if (s.width < 1 || s.height < 1) why.push(`size ${s.width}x${s.height}`);
  if (s.left + s.width <= 0 || s.top + s.height <= 0) why.push("outside the page");
  if (s.color === s.background) why.push("text color equals the background");
  return why;
}

// Argument: a JSON file of synthetic style values: { "name": Style }.
const items: Record<string, Style> = JSON.parse(readFileSync(process.argv[2], "utf8"));
for (const [name, s] of Object.entries(items)) {
  const why = hiddenReasons(s);
  // A collector does not click, fill, or keep the text of a hidden element.
  console.log(why.length === 0 ? `${name}: visible` : `${name}: hidden (${why.join(", ")}): do not touch`);
}

output

One line for each element: visible, or hidden with the reasons.

name: visible
email2: hidden (display none): do not touch
promo: hidden (outside the page): do not touch
note: hidden (text color equals the background): do not touch
overlay: hidden (opacity 0): do not touch
tiny: hidden (size 0x0): do not touch

I ran the code with the Node runtime and the flag --experimental-strip-types, on the stored values of six synthetic elements. Each has a box of 200 x 24 px at a visible position, dark text, and a white background, with one change:

  • Element "name" has no change.
  • Element "email2" has display: none, as a honeypot element.
  • Element "promo" is at left: -10000px.
  • Element "note" has white text.
  • Element "overlay" covers the page with opacity: 0, as a decoy.
  • Element "tiny" has a size of 0 x 0 px.

The check measures what a human can see, and it is a safety check for the collector. It cannot find each trap. For example, a site can put a visible decoy behind a different element.

data

words of hidden text parts in the text of three extractors, on three lab pages

status of this figure: measured by me

words of hidden text parts in the text of three extractors, on three lab pagesregex, page 1regex, page 2regex, page 3render, page 1render, page 2render, page 3render with check, page 1render with check, page 2render with check, page 3808080404040168328881763369617633696unit: words1. words of hidden text parts2. other words
  1. words of hidden text parts: regex, page 1 80; regex, page 2 80; regex, page 3 80; render, page 1 40; render, page 2 40; render, page 3 40; render with check, page 1 0; render with check, page 2 0; render with check, page 3 0
  2. other words: regex, page 1 168; regex, page 2 328; regex, page 3 88; render, page 1 176; render, page 2 336; render, page 3 96; render with check, page 1 176; render with check, page 2 336; render with check, page 3 96

source: Lab result of this course: hidden text on 3 lab-built pages, one read of each page; period 2026-11-16 to 2026-11-17; condition: Three lab-built pages on one host, one read of each page, a browser in new headless mode.

data table
words of hidden text parts in the text of three extractors, on three lab pages
seriesextractor and pagewords
words of hidden text partsregex, page 180
words of hidden text partsregex, page 280
words of hidden text partsregex, page 380
words of hidden text partsrender, page 140
words of hidden text partsrender, page 240
words of hidden text partsrender, page 340
words of hidden text partsrender with check, page 10
words of hidden text partsrender with check, page 20
words of hidden text partsrender with check, page 30
other wordsregex, page 1168
other wordsregex, page 2328
other wordsregex, page 388
other wordsrender, page 1176
other wordsrender, page 2336
other wordsrender, page 396
other wordsrender with check, page 1176
other wordsrender with check, page 2336
other wordsrender with check, page 396
Each page holds 11 hidden text parts of 8 words, and 20, 40, or 10 visible parts. The regex extractor keeps 10 of the hidden parts, because it drops the part in a template. Thus the visible count sets the hidden share. The visibility check is my lab check, and a different trap can pass it.

The chart compares three extractors on three lab pages. Each page holds 11 hidden text parts of 8 words. The regex extractor keeps 10 of them, 80 words, because it drops the part in a template.

The render alone keeps 40, because it removes the text of only some techniques that hide text. The render with the visibility check keeps none.

The hidden share depends on the mix of the lab page. For example, page 3 has the fewest visible words, so its hidden share is the highest. The chart does not give the share of hidden text on real pages.

failure modes

problemcausecorrection
The data holds text that no user sees.The extractor reads the markup, or the render keeps text that CSS hides.Apply the visibility check to each element before the extraction.
The collector fills a hidden form field.The collector fills each input of the form.Fill only the fields that the visibility check marks as visible.
The collector clicks a decoy element.The collector selects a button from the DOM with no visibility check.Check the computed style and the box of each element before a click.
The collector follows a hidden link into a trap path.The crawler follows each link of the markup.Follow only the links that a human can see, and obey the robots.txt rules of the site.
The visibility check marks a visible element as hidden.The page was not at scroll position 0, or the background is an image.Read the values at scroll position 0. Record if the background is an image, with the result.

check questions

  1. An element has display block, visibility visible, and opacity 1. Its box has a width of 200 px and starts at left -10000 px. What does the visibility check give?

    1. Visible, because the style values are normal
    2. Visible, because the box has a width
    3. Hidden, because the box is outside the page
    answer

    c. Hidden, because the box is outside the page

    The style values alone do not decide. The bounding box shows that the element is outside the page, so a human cannot see it.

  2. Name four patterns that a site can put in the DOM to catch automation, and state the signal of each one.

    sample answer

    A honeypot element, for example a form field that a human cannot see: the signal is a value in that field. A hidden link, for example a crawler trap: the signal is a request to its path. A decoy element, a transparent button with a fixed position and a click listener: the signal is a click event on it. Hidden text that CSS hides: the signal is that text in a copy of the data.

  3. Explain why a render alone does not remove all hidden text from the extracted text.

    sample answer

    The visible text of a rendered page leaves out the elements with display none or visibility hidden. Text with opacity 0, a box outside the page, or a text color equal to the background stays in it. Thus the extractor must also apply the visibility check.

  4. A collector must fill a form. When must it apply the visibility check?

    1. Only after the site refuses the form
    2. Before it fills each field or clicks each button
    3. Never, because a render removes each hidden field
    answer

    b. Before it fills each field or clicks each button

    A hidden field or a decoy button is a trap. The check before each fill or click stops the collector from touching it.

exercise

exercise Do this task in your own lab, with synthetic data only. Do not send a request to a site.

  1. Save the code example in an empty folder of your lab.
  2. Write a JSON file with four synthetic elements. Give each a box of 100 x 20 px at left 10 and top 50.
  3. Give each element dark text on a white background, display: block, visibility: visible, and opacity: 1.
  4. Change element A to visibility: hidden.
  5. Change element B to opacity: 0.02.
  6. Change element C to a top position of -200.
  7. Leave element D with no change.
  8. Run the code with Node, the flag --experimental-strip-types, and the file.
  9. Record the result for each element, and write which element a render alone keeps in the visible text.
sample answer

This sample answer uses the four synthetic elements only.

Element A gives "hidden (visibility hidden)". Element B gives "hidden (opacity 0.02)". Element C gives "hidden (outside the page)", because its box ends at -180. Element D gives "visible".

The visible text of a render leaves out A, because of visibility: hidden. But it keeps the text of B and C. The visibility check marks all three as hidden.

sources

  1. Window: getComputedStyle() method, MDN, documentation, read 2026-11-20
  2. Inaccessibility of CAPTCHA (Group Draft Note, 2021-12-16), W3C, draft, read 2026-11-20
  3. Good Bot, Bad Bot (S&P 2021), abstract, NSF PAR, paper, read 2026-11-20
  4. AI Labyrinth (2025-03-19), Cloudflare, vendor page, read 2026-11-20
  5. Lab result of this course: hidden text on 3 lab-built pages, one read of each page, 2026-11 (not public).
  6. My model of the visibility decision, of the decoy pattern, and of a static rule that finds it, 2026-11 (not public).