Page structure: what a screen reader leaves of your website
AccessibilityA website has two versions.
9 min read
By Timo Wessels Published
A website has two versions. One you see: colours, images, columns, spacing. The other goes to screen readers (programs that read the page aloud), search engines and AI systems, and it consists of structure only.
If this second version is only a row of meaningless boxes, the first helps nobody. For these readers it is not there at all.
The most important points first:
- Use the fitting HTML element for each piece of content, not the one that looks good.
- A page needs areas: header, navigation, exactly one main content and footer.
- A skip link at the start,
lang="en"and a title of its own per page are the cheapest improvements.
What arrives at the screen reader
The browser builds two things from your HTML. The first is the DOM, the complete structure of all elements from which the visible page arises. The second is the accessibility tree. web.dev describes it like this: the browser takes the DOM and changes it into a form that is useful to assistive technology. That is what the screen reader actually gets.
In the tree, what counts above all are the role, name, state and value of an element. For example, an <h1> becomes the role “heading, level 1”, and an <img> becomes an element whose name comes from the alt attribute. A <button> is a button with the state active or disabled. web.dev writes: with the right element, role, state and value are covered. You only have to make sure it has a name.
A <div> or <span> without further statements tells the assistive tool nothing. A <div> with a click event that looks like a button cannot be reached with the keyboard, is not announced as a button and does not react to Enter. A <button type="button">Request a quote</button>, by contrast, is recognisable and operable without extra work. Rheinwerk describes this, Barrierefreie Webseiten, ch. 3.7.
That is the core: use the right element, and you save yourself most of the work.
Semantic HTML
Semantics means choosing an element by what the content is, not by how it should look. Almost every HTML element carries a meaning. Exceptions are <div> and <span>. They are pure containers (Rheinwerk, ch. 3.2).
<!-- without meaning -->
<div class="heading">Services</div>
<div class="text">We offer three services:</div>
<div class="list">
<div>Accessibility check</div>
<div>Load time analysis</div>
<div>Maintenance</div>
</div>
<!-- with meaning -->
<h2>Services</h2>
<p>We offer three services:</p>
<ul>
<li>Accessibility check</li>
<li>Load time analysis</li>
<li>Maintenance</li>
</ul>
Both versions can look the same. In the second, though, the screen reader says “heading level 2, services” and “list with three items”. The user knows what to expect and can jump straight to the list. In the first they hear three words with no connection.
The same goes for search engines and AI systems: they read the structure, not the look.
The rule behind it is WCAG 1.3.1 “Info and Relationships”, Level A. The WCAG are the international guidelines for accessible websites. Structure and relationships that you can see must also be in the code.
The areas of a page
HTML has elements that mark whole page areas. They are called landmarks. A screen reader can show the list of these areas and jump straight to them.
| Element | What it marks |
|---|---|
<header> |
Header with logo, title, often the navigation |
<nav> |
Navigation area |
<main> |
The main content of the page |
<article> |
Self-contained content |
<section> |
A thematically coherent section |
<aside> |
Side content, sidebar, extra information |
<footer> |
Footer with contact, legal links, copyright |
A complete basic frame:
<body>
<a href="#content" class="skip-link">To the content</a>
<header>
<a href="/"><img src="logo.svg" alt="Home, Musterbetrieb"></a>
<nav aria-label="Main navigation">
<ul>
<li><a href="/services">Services</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
</header>
<main id="content">
<h1>Services</h1>
<p>…</p>
</main>
<footer>
<p>Musterbetrieb GmbH · <a href="/imprint">Imprint</a></p>
</footer>
</body>
Several <nav> need names. MDN writes that a document may have several <nav>, for example one for site navigation and one for jumps within the page. The W3C’s guide to landmarks says: if a role is used more than once, each instance gets a label of its own. The name should only describe, not repeat the role. “Main navigation” fits, “Main” is better still, because the screen reader says “navigation” itself.
There is one <main> per page. MDN: a document must not have more than one visible <main>. It is the area that screen reader users jump to directly to skip the header.
The skip link
WCAG 2.4.1 “Bypass Blocks” (Level A) requires a way to skip repeated areas. On every subpage the same twenty menu items stand. Whoever moves linearly through the page, by keyboard or screen reader, would have to go through them again on each page before the actual content begins.
The usual solution is a skip link as the very first element in the <body>:
<a href="#content" class="skip-link">To the content</a>
It is normally invisible and becomes visible as soon as it gets focus:
.skip-link {
position: absolute;
inset-block-start: -100%;
}
.skip-link:focus {
position: static;
}
It must not be hidden with display: none. Then it is gone for the keyboard too.
Two mistakes I see regularly in practice:
- The skip link is there but does not become visible when focused. For sighted people the focus then seems to jump into nothing.
- The skip link points to an
idthat does not exist. Then nothing happens.
A properly placed <main> with an id and a skip link that becomes visible and points to it are the whole solution.
The order in the source
WCAG 1.3.2 “Meaningful Sequence” (Level A): if meaning depends on the order, a correct reading order must be determinable from the code.
Screen readers read from top to bottom. What stands fourth in the source comes fourth.
The conflict arises from modern CSS. Grid layouts can arrange elements freely. An element that comes first in the code can land at the bottom right visually. For sighted people it is then right, for everybody else not.
An example (Rheinwerk, ch. 3.5): a product image sits visually above the heading. In the code it must still come after the heading, because the heading announces what it is about.
The rule for practice: write the source in the order in which you would read the content aloud, and then arrange it with CSS. Not the other way round. That also concerns the switch between desktop and smartphone. If columns appear in a different order on the phone, at least one of the two is wrong.
Two small things with a big effect
The language statement. WCAG 3.1.1 (Level A) requires that the main language of a page is stated in machine-readable form, so that assistive technology renders content in the right language. At the very top of the document:
<html lang="en">
Without it the screen reader has to guess the language and in doubt reads English text with another language’s pronunciation. For single foreign-language passages the same applies on a small scale:
<p>The method is called <span lang="de">Barrierefreiheit</span>.</p>
The page title. WCAG 2.4.2 (Level A) requires titles that describe topic or purpose. The W3C names the benefit: titles help to recognise and tell pages apart. Every page therefore needs a title of its own that says something. Five subpages with the title “Home” are a real finding.
How to check it yourself
- See the structure. The browser extension HeadingsMap shows headings and landmarks as an outline. The extension Web Developer marks headings and areas directly on the page. Both are free (Rheinwerk, ch. 3.4).
- The developer tools. In Chrome and Edge the “Accessibility” pane shows role, name and states of a selected element. It is the most exact answer to what arrives here.
- The landmark list in the screen reader. In NVDA the elements list (NVDA+F7) shows areas. If it says only “main”, the landmarks are missing.
- The Tab test for the skip link. Load the page, press Tab once. Does a skip link appear? Does it lead to the content?
- The look at the source. Right-click, view page source. Search for
<main,<nav,<header,<footer. If none occurs and<div class="…">stands everywhere, you have your result.
What you can do
1. First check what your theme brings. Most of these elements come from the theme and not from your content. A cleanly built theme sets <header>, <nav>, <main> and <footer> itself and brings a working skip link. A badly built one sets <div> everywhere. In choosing a theme this difference matters more than any design feature. That is why in a rebuild I would rather exchange the foundation than repair a hundred single spots.
2. Set lang, if it is missing. It is the cheapest find of all.
3. Give every <nav> a name.
4. Make sure exactly one <main> exists and the skip link points to it.
5. When building content, use the intended formats in the editor: heading, list, quote. Do not rebuild text visually. A list made of paragraphs with a hyphen in front looks like a list and is none. The effort is the same, the result is not.
Sources
- web.dev, The Accessibility Tree — the accessibility tree as a changed version of the DOM for assistive technology; role, name, state and value; the right element covers role, state and value: web.dev(external site: web.dev)
- W3C, Understanding SC 1.3.1: Info and Relationships — structure and relationships must be in the code, Level A: w3.org(external site: w3.org)
- W3C, Understanding SC 1.3.2: Meaningful Sequence — correct reading order from the code, Level A: w3.org(external site: w3.org)
- W3C, Understanding SC 2.4.1: Bypass Blocks — being able to skip repeated blocks, Level A: w3.org(external site: w3.org)
- W3C, Understanding SC 3.1.1: Language of Page — the page language in machine-readable form, Level A: w3.org(external site: w3.org)
- W3C, Understanding SC 2.4.2: Page Titled — titles that describe topic or purpose, Level A: w3.org(external site: w3.org)
- W3C, Landmark Regions, ARIA Authoring Practices Guide — landmarks; for repeated use, a label of its own per area: w3.org(external site: w3.org)
- MDN, The Main element — no more than one visible
<main>per document: developer.mozilla.org(external site: developer.mozilla.org) - MDN, The Navigation Section element — several
<nav>are allowed: developer.mozilla.org(external site: developer.mozilla.org) - Rheinwerk, Barrierefreie Webseiten, ch. 3.2, 3.4, 3.5, 3.7 and 8.1 — semantics,
<div>and<span>as meaningless elements, the HTML5 area elements, the example on the order of image and heading, the accessibility tree, the skip link, HeadingsMap as a testing tool. - Own testing practice — the two most frequent skip link mistakes, naming several navigation areas, the quick source test, theme quality as the biggest lever, rebuilt lists in the editor.