This analysis documents an experiment designed to test the extraction of structured content from HTML pages with different layout patterns. The goal was to find out which HTML structures let information be extracted successfully and which ones are a challenge for automated reading systems.
I tested 16 variants of HTML pages, each one containing product information (name, description and price) but structured in radically different ways. The results reveal some interesting patterns in how extraction systems interpret web content.
How content extraction works in LLMs
When LLMs scrape web pages through their built-in tools (like web_fetch in Claude, the web tool in ChatGPT...), they usually don't execute JavaScript. It's a simple HTTP request that downloads the static HTML from the server. This means that:
- JavaScript isn't executed
- CSS styles aren't rendered
- There's no visual/rendering context
- You only get the raw HTML from the server
If the system uses a browser with no UI (headless), JS does get executed and the dynamic DOM can be rendered (Puppeteer/Headless Chrome, Playwright). Some agents and scrapers explicitly do this, like Gemini with Googlebot.
Some pipelines use Readability-style extractors (Readability is what Firefox Reader View uses) to detect the “main content” (based on heuristics), and sometimes convert it to Markdown with libraries like Turndown.js. That said, this isn't universal. Others (like the ones based on APC in Chromium's Blink) generate a structured representation of the layout tree (with text, images, forms, geometry, roles), and can then offer “views” such as structured Markdown or passage “chunks”. It's not just a simplified “reader mode”.
LLMs don't see the full HTML. Extraction heuristics filter out what they consider "noise" before passing the content to the model. Basically, the process goes like this:
Raw HTML → Detection algorithm → "Main" content
Extractors like Readability use documented heuristics (text density, link density, class/ID names used as positive/negative signals) and tend to deprioritize boilerplate (nav/footer/aside), but there's no universal rule. Also, in structural pipelines (APC) the source is the layout tree, and the weight comes from structure/role/visibility.
Claude's behavior in the experiment is consistent with a heuristic extractor like Trafilatura/Readability (boilerplate filtering, sensitivity to structural cohesion, weight of the H1). Anthropic hasn't published which specific library it uses internally, but the patterns I observed fit that family of pipelines. Also, I found the abbreviation "traf" in the internal schema of Anthropic's extractor, which suggests (but doesn't confirm) that it's Trafilatura.
So the system identifies what counts as "main content" using heuristics like:
- Text density in containers
- Removing "non-content" elements.
- Elements considered "noise" are removed or ignored:
// Elements typically filtered out as boilerplate
<nav>, <footer>, <aside>, <script>, <style>,
<iframe>, <meta>, HTML comments
This is one of the reasons why no web fetch tool inside an LLM reads schema.
Note: In APC, as I mentioned earlier, this is done from the layout tree, and what gets included depends on visibility, role, and whether the content is "user-visible", but scripts are explicitly excluded.
Methodology
Each HTML file contained the same basic information about a fictional product, but presented with different layout patterns:
- Variations in div nesting depth
- Semantic vs. non-semantic elements
- Different positions for the price in the DOM
- Structures with lists, blockquotes and heading elements
- Plain text with line breaks
- Semantic HTML5 structures (article, section, header, footer)
This was the prompt (translated from Spanish):
Go to each of these URLs, one after the other, and extract the product information. Reply with the product name, description and price. If you can't find a field, write "empty":
URL1
URL2
...
Please format your answer like this for each URL:
URL: [URLN]
- Product name: [whatever you find]
- Description: [whatever you find]
- Price: [whatever you find]
I ran this experiment on Gemini, ChatGPT and Claude, with all their production models, in temporary chat mode (no persistent memory). However, only Claude's results are documented here, because with the other AIs the extraction worked regardless of the HTML structure used.
To rule out possible hallucinations and validate the results, I ran a second round of tests, checking each URL one by one. This time, I specifically asked the model to return all the visible text on the page. The results were identical to the first extraction, which confirms that the limitations I saw are consistent and not the result of random model errors.
Results
Category 1: Nested DIVs
Example 1a: Basic nested DIVs ❌
<div>
<div>
<div>
<div>
<div>TechStore Premium</div>
<div>Monitor UltraWide 34"</div>
<div>Resolución 3440x1440, 144Hz, panel IPS con HDR400.</div>
<div>
<div>$899.00</div>
<button>Comprar ahora</button>
</div>
</div>
</div>
</div>
</div>
Result:
- Name: Monitor UltraWide 34"
- Description: Resolución 3440x1440, 144Hz, panel IPS con HDR400.
- Price: empty
Example 1b: Nested DIVs with Schema microdata ❌
<body>
<div itemscope itemtype="https://schema.org/Product">
<div>
<div>
<div>
<div>
<div itemprop="brand" itemscope itemtype="https://schema.org/Brand">
<span itemprop="name">TechStore Premium</span>
</div>
<div itemprop="name">Monitor UltraWide 34"</div>
<div itemprop="description">
Resolución 3440x1440, 144Hz, panel IPS con HDR400.
</div>
<div itemprop="offers" itemscope itemtype="https://schema.org/Offer">
<div>
<meta itemprop="priceCurrency" content="USD">
<span itemprop="price" content="899.00">$899.00</span>
</div>
<button>Comprar ahora</button>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
Result:
- Same as the previous one.
Example 1c: More deeply nested DIVs ❌
<div>
<div>
<div>
<div>
<div>
<div>TechStore Premium</div>
<div>Monitor UltraWide 34"</div>
<div>Resolución 3440x1440, 144Hz, panel IPS con HDR400.</div>
<div>
<div>
<div>$899.00</div>
<button>Comprar ahora</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Result: Same as the previous one: the price wasn't extracted.
Example 1d: Price outside the main container ❌
<div>
<div>
<div>
<div>
<div>TechStore Premium</div>
<div>Monitor UltraWide 34"</div>
<div>Resolución 3440x1440, 144Hz, panel IPS con HDR400.</div>
</div>
</div>
</div>
<div>$899.00</div>
<button>Comprar ahora</button>
</div>
Result: Price not extracted, even though it sits at the same hierarchy level as the main container.
Example 1f: Price with the currency symbol at the end ❌
<div>
<div>
<div>
<div>
<div>TechStore Premium</div>
<div>Monitor UltraWide 34"</div>
<div>Resolución 3440x1440, 144Hz, panel IPS con HDR400.</div>
</div>
</div>
</div>
<div>899.00$</div>
<button>Comprar ahora</button>
</div>
Result: Price not extracted, regardless of the currency format.
Example 1e: Price inside the container ✅
<div>
<div>
<div>
<div>
<div>TechStore Premium</div>
<div>Monitor UltraWide 34"</div>
<div>Resolución 3440x1440, 144Hz, panel IPS con HDR400.</div>
<div>$899.00</div>
</div>
</div>
</div>
<button>Comprar ahora</button>
</div>
Result:
- Name: Monitor UltraWide 34"
- Description: Resolución 3440x1440, 144Hz, panel IPS con HDR400.
- Price: $899.00
Category 2: Semantic Elements
Example 2: UL list ✅
<ul>
<li>CameraWorld</li>
<li>Cámara Mirrorless Z9</li>
<li>Sensor full frame 45MP, video 8K, estabilización IBIS de 5 ejes.</li>
<li>$4,599.99</li>
<li><button>Añadir al carrito</button></li>
</ul>
Result: Full, successful extraction. Lists provide a clear, sequential structure.
Example 3: Blockquote ✅
<blockquote>
<cite>AudioTech Solutions</cite>
<q>Micrófono Podcast Pro USB</q>
<p>Patrón cardioide, filtro pop integrado, monitoreo zero-latency.</p>
<strong>$229.90</strong>
<button>Ordenar</button>
</blockquote>
Result: Full extraction. Claude doesn't filter out <blockquote>, <cite> or <q>.
Example 4: Headings out of order ✅
<h6>SmartHome Express</h6>
<h3>Termostato Inteligente WiFi</h3>
<h5>Control desde app, programación automática, ahorro energético del 30%.</h5>
<h4>$179.00</h4>
<h2><button>Comprar producto</button></h2>
Result: Full extraction, despite the non-semantic heading order. Heading elements carry enough weight to be taken into account.
Example 5: Plain text with BR ✅
<body>
GamerPro Shop<br>
Mouse Gaming RGB Elite<br>
16000 DPI ajustable, 11 botones programables, peso personalizable.<br>
$89.99<br>
<button>Agregar</button>
</body>
Result: Full extraction. Plain text with line breaks is easy to read as sequential content.
Category 3: Semantic HTML5
Example 6: Chaotic article-section ❌
<section>
<article>
<section>FitTech Wearables</section>
<article>Banda Fitness Pro 6</article>
</section>
<aside>Medición SpO2, sueño, 120 modos deportivos, batería 14 días.</aside>
<article>
<section>$149.50</section>
<button>Adquirir ahora</button>
</article>
</section>
Result:
- Name: Banda Fitness Pro 6
- Description: empty
- Price: $149.50
The description was in an aside element, which seems to have been filtered out.
Example 7: Article with header and footer ❌
<article>
<header>
<p>ElectroGaming Store</p>
<h1>Consola Retro Arcade Plus</h1>
</header>
<p>Emulador con 10,000 juegos clásicos, HDMI 4K, 2 controles inalámbricos incluidos.</p>
<footer>
<span>$349.99</span>
<button>Comprar ahora</button>
</footer>
</article>
Result:
- Name: Consola Retro Arcade Plus
- Description: Emulador con 10,000 juegos clásicos, HDMI 4K, 2 controles inalámbricos incluidos.
- Price: empty
The price inside the footer wasn't extracted, even though that's a valid place for it.
Example 8: Simple article ✅
<article>
<h1>Tablet Pro Max 12.9"</h1>
<p>TechDigital Corporation</p>
<p>Pantalla OLED 120Hz, chip M2, 8GB RAM, compatible con stylus, teclado magnético.</p>
<p>Precio: <strong>$1,199.00</strong></p>
<button>Añadir al carrito</button>
</article>
Result: Full, successful extraction. A simple, clear structure inside an article.
Category 4: Traditional HTML
Example 9a: Traditional HTML with H3 ❌
<div>
<h3>Smartphone Galaxy Ultra 5G</h3>
<p><strong>Marca:</strong> PhoneTech Global</p>
<p><strong>Descripción:</strong> Cámara 200MP con zoom 10x, batería 5000mAh, pantalla AMOLED 6.8", procesador Snapdragon 8 Gen 3.</p>
<p><strong>Precio:</strong> $999.00</p>
<button type="button">Comprar ahora</button>
</div>
Result:
- Name: empty
- Description: Cámara 200MP con zoom 10x, batería 5000mAh, pantalla AMOLED 6.8", procesador Snapdragon 8 Gen 3.
- Price: $999.00
The product name in the H3 wasn't identified as such. The extractor's heuristics may ignore an H3 inside a div.
Example 9b: Traditional HTML with H2 ❌
<div>
<p>SportTech Equipment</p>
<h2>Bicicleta Eléctrica Mountain Pro</h2>
<p>Motor 750W, batería 48V, autonomía 80km, suspensión delantera, frenos hidráulicos.</p>
<p>Precio: $2,299.00</p>
<button>Comprar ahora</button>
</div>
Result:
- Name: empty
- Description: Motor 750W, batería 48V, autonomía 80km, suspensión delantera, frenos hidráulicos.
- Price: $2,299.00
Similar to the previous case: the H2 wasn't identified as the product name, possibly for the same reason.
Example 9c: Traditional HTML with H1 ✅
<div>
<p>HomeComfort Store</p>
<h1>Robot Aspiradora Smart Clean X9</h1>
<p>Navegación láser LiDAR, mopa integrada, vaciado automático, control por app.</p>
<span>$649.99</span>
<button>Añadir al carrito</button>
</div>
Result: Full extraction.
Pattern analysis and conclusions
This analysis has important implications for web developers who want automated systems to interpret their content correctly. It revealed several patterns about which HTML structures make content extraction easier:
- Container cohesion: Related content should stay at the same nesting level inside a shared container. When elements like the price are placed in extra nesting levels or outside the main container, the extraction system doesn't correctly associate them with the rest of the product. Extraction doesn't fail because something is inside a div, but because the structural cohesion is broken.
- Semantic hierarchy: Elements with more semantic weight (H1, article, lists) are recognized more easily. In the traditional HTML examples (9a, 9b and 9c), the H1 was identified as the product name, while the H2 and H3 weren't (in Example 4, where everything is a heading, the H3 was extracted). This suggests the system prioritizes the highest-level elements in the document.
- Structural simplicity: Simple, straightforward structures (plain text with BR, linear lists) were extracted successfully.
- Specific semantic elements: Some HTML5 elements seem to get special treatment:
- footer: Its content isn't extracted, probably because it's treated as meta-information or secondary content, even when it's inside an article.
- aside: It also seems to be filtered out, treated as tangential content.
- header: Its content does get processed.
Although other AIs like Gemini and ChatGPT had no extraction problems in this experiment, that doesn't mean we can ignore HTML structure. The way "reader mode" converts content into plain text carries semantic meaning that comes directly from the DOM. A well-structured page makes the content easier to put in context and understand, regardless of which model processes it.
The fact that some models are better at making up for structural flaws doesn't free us from the responsibility of writing correct HTML. A clear semantic structure:
- Reduces ambiguity in how content is interpreted
- Makes context easier to grasp for every extraction system
- Improves accessibility for screen reader users
- Ensures more consistent and predictable extraction by any extraction system, whether it's an LLM or a search engine.
In short, just because your content "works" with some tools doesn't mean it's well structured. Correct semantic HTML is an investment in robustness and future compatibility.
Related
Web Agents and the Importance of Semantic, Accessible HTML
Agentic Traffic: How AI Agents Browse the Web and What You Need to Know