-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
197 lines (178 loc) · 8.96 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Accessible Breadcrumb Navigation</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/--demo-only--.css">
<link rel="stylesheet" href="assets/css/breadcrumbs.css">
</head>
<body id="body">
<div id="page" class="demo-wrap">
<main aria-label="Content">
<div class="demo-wrap__header">
<h1 class="demo-wrap__header__title">
Accessible Breadcrumb Navigation Pattern
</h1>
<p>Published: <span>April 3, 2017</span></p>
<p>Last updated: <span>August 12, 2022</span></p>
<nav>
<a href="https://github.com/scottaohara/a11y_breadcrumbs">See source on GitHub</a>
</nav>
</div>
<div class="demo">
<p>
Examples of a breadcrumb navigation using <code>aria-label</code> to provide an accessible name, and <code>aria-current</code> to indicate the currently active link.
</p>
<h2>Example: using "<code>aria-current=page</code>" on last link</h2>
<nav class="breadcrumb-nav" aria-label="Breadcrumb example">
<ol role=list>
<li>
<a href="#">
Index
</a>
</li>
<li>
<a href="#">
Second Page
</a>
</li>
<li>
<a href="#" aria-current="page">
This Page
</a>
</li>
</ol>
</nav>
<h2>Example: using "<code>aria-current=location</code>" on last link</h2>
<nav class="breadcrumb-nav" aria-label="Breadcrumb example 2">
<ol role=list>
<li>
<a href="#">
Index
</a>
</li>
<li>
<a href="#">
Second Page
</a>
</li>
<li>
<a href="#" aria-current="location">
This Page
</a>
</li>
</ol>
</nav>
<h2>Example: using "<code>aria-current=location</code>" on last list item</h2>
<nav class="breadcrumb-nav" aria-label="Breadcrumb example 3">
<ol role=list>
<li>
<a href="#">
Index
</a>
</li>
<li>
<a href="#">
Second Page
</a>
</li>
<li aria-current="page">
This Page
</li>
</ol>
</nav>
<section class="demo-details">
<h3>
Pattern Details
</h3>
<details open>
<summary>Pattern Markup</summary>
<pre><code class="language-html"><nav class="breadcrumb-nav" aria-label="Breadcrumb">
<ol>
<li>
<a href="/">
Index
</a>
</li>
<li>
<a href="/pg2">
Second Page
</a>
</li>
<li>
<a href="/pg2/this-pg" aria-current="page"> <!-- or "location" -->
This Page
</a>
</li>
</ol>
</nav>
<!-- example without a link in the last list item -->
<nav class="breadcrumb-nav" aria-label="Breadcrumb example 2">
<ol>
<li>
<a href="#">
Index
</a>
</li>
<li>
<a href="#">
Second Page
</a>
</li>
<li aria-current="location">
This Page
</li>
</ol>
</nav></code></pre>
</details>
<p>
Breadcrumbs are useful on large websites where pages have clearly defined hierarchy. These navigation patterns can allow users to easily backtrack through related pages, or the pathway they had taken to reach the current page.
</p>
<p>
Breadcrumbs aren't meant to be used for single-level websites, where there are no logical groupings of related content. For slightly more complex websites, where there may only be some instances of leveled navigation groupings, breadcrumbs may still not be necessary if they don't provide much in the way of a simplified user experience over using the primary navigation.
</p>
<h4>Screen Reader Announcements?</h4>
<p>
You may notice that the dividers between each link/list item of the breadcrumb are created via CSS pseudo elements. Originally I had used CSS <code>content: "/\00a0";</code> with <code>speak: none;</code> as a divider. However, even though added by CSS, screen readers like NVDA would announce the "slash" if navigating by list items, and VoiceOver would even move focus to the "/" if navigating with <kbd>VO + left/right</kbd> arrow keys. <code>speak: none</code> has no practical support, which is unfortunate.
</p>
<p>
Using CSS to create a arrow/triangle (or any other sort of divider that can be made with CSS alone) will allow for a visual separator that won't be announced by a screen reader. It also won't require additional list items containing the divider, or a <code><span></code> containing something like a "/" to be added to each necessary list item, just to then be hidden with <code>aria-hidden="true"</code> so it's not announced or included in the number of items in the list.
</p>
<p>
macOS and iOS will not report a <code><ol></code> as a list <a href="https://www.scottohara.me/blog/2019/01/12/lists-and-safari.html">when removing its default list markers</a>. A `role=list` can be added to the <code><ol></code> element to make sure the announcement of the list remains.
</p>
<p>
Note that screen reader support for <code>aria-current</code> is rather good. As of Dec 2021, most gaps in implementation support have been filled. If you find a screen reader / browser pairing that does not support <code>aria-current</code>, you should file a bug.
</p>
<h4>Usage note</h4>
<p>
Being that a breadcrumb is contained within a <code><nav></code> element, it will be surfaced as a landmark to screen readers. Providing it an accessible name of "breadcrumb" (or whatever term may be more meaningful to your site) will help differentiate it from any other navigation landmarks in the current document, such as the "primary" navigation.
</p>
<p>
The last link in the breadcrumb should have the <code>aria-current</code> attribute, which either have the value of <code>page</code> or <code>location</code>. The value you choose is largely up to you since both make sense in the context of the breadcrumb pattern. e.g., the last link in the breadcrumb is the current "page", while also serving as the current "location" in the breadcrumb trail. Note that if using <code>aria-current</code> in primary navigation patterns, the <code>page</code> value is what would be expected there.
</p>
<p>
Some other breadcrumb patterns remove the <code><a></code> element, or at least the <code>href</code> from the link. This is demonstrated in the third example, where the first two examples keep the last item in the breadcrumb as a hyperlink. One reason to keep the hyperlink is so that people using a screen reader and navigating by links, or via focusable content with the <kbd>tab</kbd> key would not come across the currently active link. The counter argument for using a hyperlink in the last breadcrumb list item is that, since it represents the current page, there's little reason to include it in the document's keyboard focus order.
</p>
</section>
<h3>
Continue reading
</h3>
<p>
For more information about the <code>aria-current</code> attribute, read
<a href="https://tink.uk/using-the-aria-current-attribute/">Using the <code>aria-current</code> attribute</a> by Léonie Watson.
</p>
<p>
Additionally, you should review
<a href="https://www.w3.org/WAI/ARIA/apg/example-index/breadcrumb/index.html">the <abbr>ARIA</abbr> Authoring Practices Guide breadcrumb navigation example</a>,
as well as the <a href="https://w3c.github.io/aria/#aria-current">ARIA specification for <code>aria-current</code></a>.
</p>
<p>
Thank you to <a href="https://twitter.com/ZoeBijl">@ZoeBijl</a> and the APG for a more elegant solution for breadcrumb dividers, and <a href="https://twitter.com/inclusicomps">@inclusicomps</a> for reminding me that <a href="https://css-tricks.com/almanac/properties/s/speak/">CSS <code>speak</code> has poor support</a>.
</p>
</div>
</main>
</div>
</body>
</html>