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 sourcepurpose
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
- Decide if an element is visible with the computed style and the bounding box.
- Name the decoy element and honeypot element patterns of the DOM, and the signal of each one.
- Explain why a render alone does not remove all hidden text.
- 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:
displayisnone.visibilityishiddenorcollapse.opacityis near 0.- The width or the height of the box is less than 1 px.
- The box is outside the page, for example at
left: -10000px. - 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:
| pattern | what the page holds | signal for the site |
|---|---|---|
| Honeypot element | A form field that a human cannot see, for example an input with display: none | A value in that field when the form arrives |
| Hidden link | A link with no visible box, for example a crawler trap | A request to the path of the link |
| decoy element | A created button with a fixed position, opacity: 0, and a click listener | A click event on the decoy |
| Hidden text | Text that CSS hides | The 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 side | detection 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
| option | gain | cost | when it is correct |
|---|---|---|---|
| Regex extraction with no visibility check | The lowest cost for each page | Hidden text goes into the data | Feeds and pages with no hidden text |
| A render with no visibility check | Elements with display: none or visibility: hidden go out | Text with opacity: 0, a box outside the page, or a same-color text stays | Pages with client-side content and no traps |
| A render and the visibility check | The text that a human sees | More time for each element | Each page where the data must equal the visible page |
| The visibility check before each click or fill | The collector does not touch a trap | The check cannot find each trap | Each collector that clicks or fills a form |
diagram
the visibility decision for one element, from the computed style and the bounding box
the decoy pattern: a page script makes a transparent decoy and reports a click on it
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.
| method | markup | tree | computed style | layout |
|---|---|---|---|---|
| Regex on the response text | yes | no | no | no |
| DOM parse with no render | yes | yes | no | no |
| Render in a browser | yes | yes, after scripts | yes | yes |
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.
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 touchI 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: 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
- 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
| series | extractor and page | words |
|---|---|---|
| words of hidden text parts | regex, page 1 | 80 |
| words of hidden text parts | regex, page 2 | 80 |
| words of hidden text parts | regex, page 3 | 80 |
| words of hidden text parts | render, page 1 | 40 |
| words of hidden text parts | render, page 2 | 40 |
| words of hidden text parts | render, page 3 | 40 |
| words of hidden text parts | render with check, page 1 | 0 |
| words of hidden text parts | render with check, page 2 | 0 |
| words of hidden text parts | render with check, page 3 | 0 |
| other words | regex, page 1 | 168 |
| other words | regex, page 2 | 328 |
| other words | regex, page 3 | 88 |
| other words | render, page 1 | 176 |
| other words | render, page 2 | 336 |
| other words | render, page 3 | 96 |
| other words | render with check, page 1 | 176 |
| other words | render with check, page 2 | 336 |
| other words | render with check, page 3 | 96 |
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
| problem | cause | correction |
|---|---|---|
| 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
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?
- Visible, because the style values are normal
- Visible, because the box has a width
- 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.
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.
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.
A collector must fill a form. When must it apply the visibility check?
- Only after the site refuses the form
- Before it fills each field or clicks each button
- 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.
- Save the code example in an empty folder of your lab.
- Write a JSON file with four synthetic elements. Give each a box of 100 x 20 px at left 10 and top 50.
- Give each element dark text on a white background,
display: block,visibility: visible, andopacity: 1. - Change element A to
visibility: hidden. - Change element B to
opacity: 0.02. - Change element C to a top position of -200.
- Leave element D with no change.
- Run the code with Node, the flag
--experimental-strip-types, and the file. - 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
- Window: getComputedStyle() method, MDN, documentation, read 2026-11-20
- Inaccessibility of CAPTCHA (Group Draft Note, 2021-12-16), W3C, draft, read 2026-11-20
- Good Bot, Bad Bot (S&P 2021), abstract, NSF PAR, paper, read 2026-11-20
- AI Labyrinth (2025-03-19), Cloudflare, vendor page, read 2026-11-20
- Lab result of this course: hidden text on 3 lab-built pages, one read of each page, 2026-11 (not public).
- My model of the visibility decision, of the decoy pattern, and of a static rule that finds it, 2026-11 (not public).