AEO

Semantic HTML for AI Parsing: Why Div Soup Fails Extraction

Semantic HTML for AI parsing means using elements that declare what content is — main, article, section, nav and a sequential heading order — so an answer engine can extract the right passage without guessing. In my builds at webdev-saif.com in Mymensingh, div soup forces extractors to infer structure from classes and whitespace, which is why the same page can be quoted accurately one week and misread the next.

By Saif Al Jahanwebdev-saif.com

What semantic HTML tells an AI extractor

Semantic HTML for AI parsing works because an extractor starts from the DOM, not from a screenshot. When it meets main, it knows the unique content body; when it meets nav, it can discard navigation as boilerplate; when it meets article, it finds a self-contained claim with its own heading and byline. Answer engines and retrieval pipelines segment pages into passages, then score those passages against a query. Landmarks and headings are the boundaries they use. A page built from nested divs gives the extractor no such signals, so it falls back to class-name heuristics and visual whitespace — both of which change when a theme or page builder is updated. I treat markup as part of the content model: the same structure a screen reader announces is the structure a crawler quotes. Get the outline right and accurate extraction follows; get it wrong and no amount of schema can repair the missing boundaries.

  • main marks the single primary content block, one per page
  • article marks a self-contained unit that can stand alone
  • section groups content under a thematic heading
  • nav marks navigation so extractors can discard it as boilerplate
  • Headings create the outline that passage retrieval splits on

main, article, section and nav: what each one declares

The four elements do different jobs and using the wrong one is common. main is the page's primary content region and there should be exactly one visible instance; it should not wrap headers, footers or sidebars. article is for a self-contained composition — a post, a case study, an FAQ answer — that would still make sense if it appeared elsewhere. section is a thematic grouping, and in practice it should carry its own heading so an extractor can name the passage it contains. nav is for navigation links; wrapping a list of related links in nav tells a parser those links are wayfinding, not the answer. A typical resource page in my work is one main containing an article, with each H2 topic as a section and a single nav for the related links. That shape is readable without CSS, which is the real test: strip the stylesheet and the document should still explain itself.

  • One main per page, placed around primary content only
  • article for content that survives being moved or syndicated
  • section paired with a heading that names the passage
  • nav reserved for navigation, not for every group of links
  • header, footer and aside excluded from main

Heading order is the outline answer engines read

Heading order is the outline an answer engine reads before it reads a single sentence. One H1 states the page's topic; H2s divide it into sections; H3s subdivide those sections. Skipping from H2 to H4 leaves a gap that both screen readers and extractors interpret as a missing parent, and using headings purely for visual size creates false top-level topics. I write the outline first as a plain list, then build markup to match it, which keeps the visual design from deciding the document structure. Page builders are the usual culprit: a heading widget wrapped in several divs still renders as an H2, but sibling widgets often lose their nesting, so an H3 meant to sit under one section appears as a top-level heading. In my WordPress themes I generate headings from the content model and disable styling overrides that change levels. Descriptive beats clever — 'Heading order is the outline an extractor reads' is quotable; 'The big idea' is not.

  • Exactly one H1 matching the search intent and visible H1
  • No skipped levels: H1 to H2 to H3 in sequence
  • Headings describe the section, not the visual style
  • One claim per section so a passage can be quoted alone
  • No headings inside nav, header or footer widgets used for styling

Why div soup makes extraction unreliable

Div soup is a document made almost entirely of generic containers, where structure exists only in class names and CSS. To a person the page looks organised; to an extractor it is a flat list of text nodes. Because it cannot tell the answer from the menu, the footer or a promotional banner, the extractor guesses — and the guess changes when a class is renamed, an ad slot is inserted, or the builder reorganises its wrappers. This is why the same page can answer a query correctly in one crawl and return a navigation snippet in the next. Passage-based retrieval makes the problem worse: it chunks by DOM depth, so deeply nested divs produce fragments that mix a heading with unrelated sibling text. Schema cannot fully rescue it, because a JSON-LD block that describes content the parser cannot locate is easy to dismiss as mismatched markup. Landmarks are the fix: they are stable names that survive a redesign.

  • No landmark for the main content, so boilerplate removal fails
  • Classes carry meaning that disappears when CSS or markup changes
  • Deep nesting splits passages across unrelated text
  • Heading levels chosen for size produce a false outline
  • Schema describes content the extractor cannot reliably locate

Building the structure in WordPress and PHP

In a WordPress build I make the semantic structure a property of the theme, not of the editor. The template owns one main element, the loop renders each entry as an article, the sidebar and footer stay outside main, and wp_nav_menu outputs navigation inside a single nav with a descriptive aria-label. For custom PHP applications I use the same rule: build the outline in the template or a small view class, and let content fill named slots rather than letting content define the structure. Content editors get fields for a heading, a body and an optional list — not a free-form HTML box where they can paste six nested divs. Where a page builder is required, I limit it to content inside an article and audit the generated output after each save. I keep the heading levels in the theme's PHP functions so an update cannot silently change them. The markup should still describe the page when JavaScript is disabled.

  • One main element in the page template, never inside a widget
  • Loop entries rendered as article with permalink and date nearby
  • wp_nav_menu output wrapped in a single labelled nav element
  • Editor fields for headings and lists instead of raw HTML pastes
  • Post-save check of builder output for skipped heading levels

Pair semantic markup with JSON-LD, not instead of it

Semantic HTML and JSON-LD solve different halves of the problem. Markup tells a parser where the answer lives; schema tells it what the entities and relationships mean. I emit one JSON-LD graph in PHP on wp_head and build its FAQPage nodes from the same array of questions the template renders, so an answer engine that quotes a passage can also resolve the author, the page type and the dateModified. Do not use schema as a shortcut around broken markup: a FAQPage block pointing at questions buried in div soup gives a crawler two conflicting descriptions and no clear passage to lift. Do not duplicate it either — microdata and JSON-LD saying the same thing in different ways adds maintenance without adding trust. Keep the visible answer, the landmark that contains it and the schema node aligned, and update them together when content changes.

  • FAQPage nodes generated from the rendered question list
  • TechArticle node with author, datePublished and dateModified
  • One canonical URL shared by rel=canonical and the @id
  • robots.txt and llms.txt checked for AI crawler access

Verify what an answer engine actually sees

Verification is cheap because the structure is predictable. Open view-source rather than the rendered DOM: the first response is what answer engines fetch, and a structure injected after hydration may as well not exist. Then strip the stylesheet and read the page top to bottom — if the outline still makes sense, the semantics are doing their job. I use a heading-outline browser extension to catch skipped levels, and a text-only extraction tool to confirm that removing navigation and footers leaves the actual answer intact. On the server side, curl the URL and grep for exactly one main, the expected H1 and the JSON-LD script. For AI visibility, check whether GPTBot, ClaudeBot and PerplexityBot are allowed in robots.txt and whether an llms.txt summary points to the page. Re-run the check after every theme or page-builder update, because markup regressions are silent until a citation goes wrong.

  • view-source on the raw HTML response, not the hydrated DOM
  • Heading-outline check for one H1 and no skipped levels
  • Text-only extraction to confirm the answer survives boilerplate removal
  • curl and grep for one main element and the JSON-LD block
  • robots.txt and llms.txt reviewed after each deployment

Frequently asked questions

What is semantic HTML for AI parsing?

Semantic HTML for AI parsing is the practice of using elements that declare meaning — main, article, section, nav and an ordered heading hierarchy — so a machine can locate the answer without guessing from class names or visual layout. It turns a page into labelled passages an answer engine can score, quote and attribute correctly, and it improves screen-reader navigation at the same time.

Does semantic HTML replace JSON-LD?

No. Semantic HTML identifies where the content is; JSON-LD states what the entities mean. Use both. A TechArticle or FAQPage graph generated from the same visible questions gives an answer engine structured facts and a clean passage to quote. Relying on schema alone while the page is div soup leaves the parser with a claim it cannot reliably place on the page.

Why is div soup a problem for answer engines?

Because divs carry no meaning. When the main content, navigation, footer and ads are all generic containers, an extractor infers structure from classes and spacing, and those cues break on the next theme or builder update. The result is inconsistent passage chunks: the right answer one crawl, a menu snippet the next. Landmarks and headings give it stable boundaries.

How many H1 tags should a page have?

One. A single H1 states the page topic and should match the visible title and the primary query intent. Use H2 for the main sections and H3 only to subdivide a section. Do not skip levels for visual effect, and do not use a heading widget solely to make text larger — style it with CSS instead so the outline remains an accurate description of the content.

Do page builders break semantic HTML?

They can. Builders often wrap headings in extra divs and place sibling widgets at the same DOM level, which flattens the outline and makes H3s look like top-level sections. In my WordPress builds I keep the page shell — main, article, nav and the heading order — in the theme, and restrict builder output to content inside a single article, then audit the saved markup.

How do I check whether my headings are in order?

Use a heading-outline extension or run a text-only extraction on the URL, then read the result without CSS. You should see one H1, H2s for each main topic and H3s nested under the right parent. For a server-side check, curl the page and inspect the raw response: it is the same HTML an answer engine fetches before any JavaScript runs.

Written by Saif Al Jahan, webdev-saif.com · Mymensingh, Bangladesh. Last updated .