All articles
165 articles · updated weekly See our Tools
All articles
All

Semantic HTML: how to structure more accessible pages

Tags like header, nav, main, and article aren't just visual organization — they define what each part of the page means to screen readers, crawlers, and SEO.

Semantic HTML: how to structure more accessible pages
COVER · All

Semantic HTML means using each element for what it means, not for how it looks: <nav> for navigation, <main> for the main content, <article> for self-contained content, <button> for a button. The browser, the screen reader and the search engine read that meaning; a <div> with a header class tells none of them anything.

Last week I opened DevTools on a client's landing page and found the opposite: a div with class header, a div with class nav, a div with class content, a div with class footer. Everything looked fine in Chrome. In a screen reader, there was no shortcut to jump to the content, no identified menu, no structure at all. It has a name, div soup, and it is more common than it should be. This post lists the semantic tags that cover almost every layout, shows a complete validated page, corrects a few SEO myths about <h1> that keep circulating, and explains where ARIA fits in (and where it shouldn't).

Why <div> and <span> aren't enough

<div> and <span> are elements without meaning. They exist to group content for styling or scripting, and that's it. Anyone reading the HTML knows something is there, but not what.

When you use <nav>, you are saying "this is navigation." <main> says "this is the main content of the page." <article> says "this is a complete unit that would make sense outside this page."

The difference shows up when you open a screen reader like NVDA or VoiceOver. Screen reader users navigate by landmarks (regions of the page) and by headings: one key jumps straight to <main>, another lists the menus, another lists the headings. In div soup those shortcuts simply don't exist, and the person has to listen to the page from top to bottom.

HTML5 semantic tags: the reference table

What each tag represents and which role it exposes to assistive technology, according to the official W3C mapping, HTML Accessibility API Mappings (HTML-AAM):

Tag What it represents Exposed role (landmark?)
<header> Header of the page or of a section banner (landmark) only when it is a child of <body>; inside <main>, <article>, <section> etc., not a landmark
<nav> Major navigation block navigation (landmark)
<main> The page's main, unique content main (landmark)
<article> Self-contained content: post, comment, card article (not a landmark)
<section> Thematic grouping, usually with a heading region (landmark) only with an accessible name; without one, generic
<aside> Related but non-essential content complementary (landmark) in <body>/<main>; inside <article>/<section>, only with an accessible name
<footer> Footer of the page or of a section contentinfo (landmark) only when it is a child of <body>
<figure> + <figcaption> Image, chart or code with a caption figure
<time> Date or time, machine-readable via datetime time
<address> Contact info for the author or owner of the page/article group
<details> + <summary> A block that opens and closes without JavaScript group, with summary as the control

The rows with "only when" are the part almost every semantic HTML article gets wrong. Let's go through them.

<header> and <footer>

They can appear many times. The <header> that is a direct child of <body> is the site header and becomes the banner landmark; the <footer> child of <body> becomes contentinfo. A <header> inside an <article> is that article's header (title, author, date) and is not announced as a banner. That is why you can, and should, use <header> inside each post without cluttering landmark navigation.

<nav>

For meaningful navigation blocks: main menu, breadcrumb, pagination, table of contents. Not for every group of links (footer links usually don't need it). If there is more than one <nav> on the page, name each one with aria-label="Main", aria-label="Breadcrumb", so the screen reader can tell them apart.

<main>

Holds what is unique to that page. The HTML specification says a document must not have more than one <main> without the hidden attribute; in other words, others can exist as long as only one is visible (useful in SPAs). And it cannot sit inside <article>, <section>, <aside>, <header>, <footer> or <nav>: the only allowed ancestors are <html>, <body>, <div>, <form> without an accessible name, and custom elements.

<article> vs <section>

The most common confusion. The practical test:

  • <article>: would it make sense on its own, in an RSS feed or shared outside the page? Blog post, product card, comment, weather widget.
  • <section>: is it a thematic part of something bigger, with its own heading? A chapter of a post, the "Specifications" block on a product page.

A post is an <article>; its chapters are <section>s; the comments are several <article>s inside a <section>.

The landmark detail: a <section> only becomes a region landmark when it has an accessible name, usually via aria-labelledby pointing at its heading (or aria-label). Without a name, HTML-AAM maps it as generic, the same as a <div> for region navigation purposes. Don't go naming every section: too many regions become noise. Name the ones someone would actually want to jump to.

<aside>

Related but non-essential content: "read next", side notes, ads. If you remove the <aside>, the main content must still make complete sense.

A complete page example

Putting it all together in a blog post. I ran this HTML through the W3C Nu HTML Checker (version 26.11.9, on November 9, 2026) and it came back with no errors or warnings:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>How to choose a laptop for programming | Example Blog</title>
</head>
<body>
  <header>
    <a href="/">Example Blog</a>
    <nav aria-label="Main">
      <ul>
        <li><a href="/articles">Articles</a></li>
        <li><a href="/about">About</a></li>
      </ul>
    </nav>
  </header>

  <main>
    <article>
      <header>
        <h1>How to choose a laptop for programming</h1>
        <p>By Rafael Duarte, <time datetime="2026-11-09">November 9, 2026</time></p>
      </header>

      <section aria-labelledby="ram">
        <h2 id="ram">How much RAM</h2>
        <p>To run Docker and a browser at the same time, 16 GB is the comfortable minimum.</p>
        <figure>
          <img src="/img/ram.webp" alt="Chart of memory usage with Docker and Chrome open" width="800" height="450">
          <figcaption>Memory usage on a normal workday.</figcaption>
        </figure>
      </section>

      <section aria-labelledby="screen">
        <h2 id="screen">Screen size</h2>
        <p>Below 14 inches, two files side by side become painful.</p>
        <details>
          <summary>What about an external monitor?</summary>
          <p>It solves things at home, not at the airport.</p>
        </details>
      </section>

      <footer>
        <address>Questions: <a href="mailto:rafael@example.com">rafael@example.com</a></address>
      </footer>
    </article>

    <aside aria-label="Read next">
      <h2>Read next</h2>
      <ul>
        <li><a href="/articles/mechanical-keyboard">Is a mechanical keyboard worth it?</a></li>
      </ul>
    </aside>
  </main>

  <footer>
    <p>&copy; 2026 Example Blog</p>
  </footer>
</body>
</html>

The landmarks a screen reader lists here: banner (the top <header>), navigation "Main", main, the two regions "How much RAM" and "Screen size", the complementary "Read next" and the contentinfo footer. The article's own <header> and <footer> stay out of that list, as they should.

Heading hierarchy: what is a rule and what is good practice

Tags structure the page; headings structure the content. Two different things usually get mixed up here.

Skipping a level is an HTML error. The current specification requires each heading to have a level lower than, equal to, or at most one greater than the previous one: an <h3> right after an <h1> is non-conforming. The Nu HTML Checker now flags it as an error ("skipping 1 heading level"). More importantly, screen reader users navigate by the heading outline; a skipped level looks like a section went missing. Use CSS for font size and headings for hierarchy.

<!-- wrong: jumps from h1 to h3 -->
<h1>Main title</h1>
<h3>Subtitle</h3>

<!-- right -->
<h1>Main title</h1>
<h2>Subtitle</h2>
<h3>Subsection</h3>

A single <h1> is good practice, not a rule. HTML allows several <h1>s (the validator doesn't complain), and Google doesn't mind either: on October 3, 2019, on Ask Google Webmasters, John Mueller said Google's systems "don't have a problem when it comes to multiple H1 headings on a page" (Search Engine Land coverage). Google Search Central's SEO starter guide goes further: there is no ideal number of headings, and from Google Search's perspective it doesn't matter if they are out of order; semantic order is "fantastic for screen readers." I still recommend one <h1> per page, with the real title of the content, because it gives screen reader users the clearest navigation. But it is an accessibility decision, not an SEO penalty you are dodging.

Semantic HTML and SEO: fact vs myth

What is documented: Google uses heading elements, such as <h1>, among the sources for the title shown in search results, alongside <title>, the main visual title and og:title (title links documentation). So a <title> and headings aligned with the page's topic help Google show the title you want.

What is myth, and I have seen it in agency blog posts:

  • "Search Console warns you about multiple <h1>s." There is no such report. And, as we saw, multiple <h1>s are not a problem for Google.
  • "Semantics improves crawl budget." Google's crawl budget guide says the topic only matters for very large sites (1 million+ pages, or 10,000+ with daily changes) and that it depends on server health (response times, 5xx errors) and demand (popularity, update frequency, URL inventory). HTML tags are not on the list.
  • "Using <article> makes Google understand it is an article." Google's own guide admits that, because the web in general is not valid HTML, it "can rarely depend on semantic meanings hidden in the HTML specification."

So what is the real SEO gain? Indirect: clear structure makes it easier to separate content from menus, good headings feed the title in search results, and the page gets better for people, which is what Google tries to measure. If you want to tell Google explicitly "this is an article, by this author, published on this date," the right tool is structured data (JSON-LD with schema.org), which complements HTML semantics. The full list of what to check is in the technical SEO checklist, and the basics of how search works in SEO for beginners.

ARIA: the first rule is not to use it

ARIA (Accessible Rich Internet Applications) is a set of attributes that add semantics where native HTML has no element: tabs (role="tablist"), complex menus, custom components. It is not a way to "fix" div soup.

The first rule of ARIA use, from the W3C itself: if a native HTML element exists with the semantics and behavior you need, use it instead of recreating it with ARIA.

<!-- bad: a div pretending to be a button -->
<div class="btn" role="button" onclick="send()">Send</div>

<!-- good: native element -->
<button type="submit">Send</button>

A <button> is already in the keyboard focus order, activates with Enter and Space, is announced as a button and takes part in forms. A <div role="button"> only gets the announcement; the rest (tabindex, keyboard, state) you implement by hand, and usually forget part of it. The same goes for <nav> versus <div role="navigation">: the result is similar, but the native tag is shorter, clearer and doesn't depend on remembering the attribute.

How to check the structure before publishing

Three quick checks I run:

  1. Nu HTML Checker (validator.w3.org/nu): catches a duplicate <main>, headings skipping levels and a <section> without a heading (that last one comes as a warning suggesting a <div> instead).
  2. DevTools accessibility tree: in Chrome, Elements tab, Accessibility pane; in Firefox, the accessibility inspector. It shows the role and name each element exposes, in other words whether your <section> became a region or not.
  3. A real screen reader for five minutes: NVDA (Windows) or VoiceOver (macOS), listing landmarks and headings. Nothing replaces hearing the page.

If you are still building the mental model of how the browser turns that HTML into a page, the post how a web page works covers the path from DNS to paint.

Frequently asked questions

What is the difference between <section> and <div>?

A <div> is a generic container with no meaning, for styling or scripting. A <section> marks a thematic section of the document and should have a heading; the validator warns when it doesn't. For assistive technology, a <section> only becomes a region landmark if it has an accessible name (aria-labelledby or aria-label). If you have no heading to put inside, a <div> is the more honest choice.

Does having more than one <h1> hurt SEO?

No. Google said in 2019 (John Mueller) that multiple <h1>s are not a problem, and the current Search Central guide says there is no ideal number of headings and no penalty for their order. One <h1> per page is still good practice for accessibility and clarity, not a Google or HTML requirement.

Can I have more than one <main> on the page?

Only one visible. The specification allows other <main> elements as long as they have the hidden attribute, which is useful in SPAs that swap screens without reloading. A <main> inside another <main> is always an error; the validator flags both situations.

Is a <header> inside an <article> different from the page <header>?

Yes. The <header> that is a child of <body> becomes the banner landmark. Inside <main>, <article>, <section>, <aside> or <nav>, it is the header of that block and is not announced as a banner. The same applies to <footer> and the contentinfo landmark.

Semantics is for whoever can't see your page

Semantic HTML is neither formalism nor an SEO trick: it is the difference between a page any agent (screen reader, keyboard navigation, search engine, an LLM extracting content) understands without inferring from appearance. Start with the skeleton (header, nav, main, footer), get the heading hierarchy right without skipping levels, name only the sections that deserve to be regions, and use native elements before ARIA. In an existing project, swapping the <div class="header">s for the right elements is an afternoon of work, and the validator tells you right away whether you got it right.

The editorial content ends here. Once the body is right, I check what goes into the <head> (title, description, Open Graph, canonical) with the Quick Tools meta tag generator; and since structure doesn't fix unreadable text, I run the colors through the contrast checker.

RD
Author
Rafael Duarte
Backend developer with a background in fintech and B2B SaaS — worked on teams that scaled APIs from zero to millions of requests. Carries enough production scars to hold strong opinions on tools, patterns and architecture decisions. Not an academic: he read the UUID RFC when he had to choose between v4 and v7 for a write-heavy table.
View profile