3.2. Page Landmarks
Introduction
Here's a myth: "People using screen readers read all the text." Not true. We are all the same: we scan the page looking for keywords until something catches our attention. Only then, we start to actually read it.
Screen Readers users usually navigate the page through headings and landmarks. We already know the importance of a solid heading structure. Now let's talk about landmarks.
Landmarks identify sections of a page, which allows SR users to orient themselves in the page and jump directly to them.
Some elements are landmarks by default, such as <main>
and <nav>
. However, in many cases, we need to explicitly add a landmark role.
<!-- Announced as "header" or "banner" by screen readers -->
<header>...</header>
<!-- When a landmark is used multiple times
an extra label should be added -->
<nav aria-label="website">...</nav>
<nav aria-label="Table of Contents">...</nav>
We can also create custom landmarks to mark important parts of the page.
<div role="region" aria-label="recommended">...</div>
<!-- or -->
<section aria-label="recommended">...</section>
Exercise
In the exercise page, there are at least four landmarks besides the main content: the primary navigation, the search, a custom landmark and another navigation on the bottom of the page.
๐ฏ Goal: Specify each landmark using the role
attribute.
Hint: You can detect the page landmarks in multiple ways:
- Screen Reader: (check SR shortcuts)
- VoiceOver: Open the router with
VO + U
- Extensions: Accessibility Insights or Landmarks extension.
Bonus
#1 Language of the content
Use a SR to read the "Good morning" part. You'll notice that it's not pronounced correctly in the three idioms presented. This can be an annoying issue for SR users who visit a page in a language different than their system settings.
To fix it, the lang
attribute needs to be added to the element that contains a different idiom.
<!-- "Hello world!" in Portuguese -->
<p lang="pt-PT">Olรก mundo</p>
๐ฏ Goal: Add the idiom of any different content.
๐ Tip: Here's a list of all ISO Language Codes to help you.
Note #1: All pages in this site have <html lang="en">
by default.
Note #2: In Windows you may not see the country flags emojis (eg ๐ซ๐ท = FR).
Note #3: Your SR might not include the foreign language required to pronounce the content with the correct accent.
#2 Content hierarchy and relations
You might be aware of <section>
and <article>
tags and wondering when to use each other.
There's no better way to discover it than by using it yourself with a screen reader.
๐ฏ Goal: Experiment replacing the comments area <div>
with section
or article
. Listen how a screen reader announces them differently.
๐ Tip: Use aria-label
or aria-labelledby
to give a name to that area.
Further reading
- Aria Roles
- W3C Landmarks Example
- Landmarks browser extension
- A 2020 study to the top 1 million webpages revelated that ~29% of the websites didn't specify the document language.
- HTML5 deep dive into article and section
WCAG Success Criterion
- WCAG 1.3.6 Identify purpose - Level AAA
- WCAG 3.1.1 Laguage of page - Level A
- WCAG 3.1.1 Laguage of parts - Level AA
- WCAG 2.4.10 Section Headings - Level AAA
Exercise takeaways
(After the exercise) Reveal takeaways
- Landmarks allow people using SR to quickly discover to the main regions of the page.
- When using multiple
<nav>
, usearia-label
to distinguish them. <section>
is not a landmark, unless it hasaria-label
attribute with the landmark title.- The language of the page must always be set with attribute
lang
to tell the SR how to red the content properly.