Examples of a breadcrumb navigation using
aria-label to provide an accessible name, and
aria-current to indicate the currently active link.
Example: current page
Example: current location
<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>
Breadcrumbs are useful on large websites where pages have clearly defined hierarchy. These navigation patterns can allow users to easily backtrack through related pages.
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.
Effects on Screen Reader Announcements?
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
content: "/\00a0"; with
speak: none; 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 VO + left/right arrow keys.
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
span containing something like a "/" to be added to each necessary list item, just to then be hidden with
aria-hidden="true" so it's not announced or included in the number of items in the list.
Note that screen reader support for
aria-current is rather good, with gaps in support with TalkBack, and with Microsoft Edge + Narrator or JAWS 2018. For a full breakdown of support, please refer to the support table on Léonie Watson's test page.
Being that a breadcrumb is contained within a
nav 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.
The last link in the breadcrumb should have the
aria-current attribute, which either have the value of
location. 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
aria-current in primary navigation patterns, the
page value is what would be expected there.
Some other breadcrumb patterns remove the
<a> element, or at least the
href from the link. These examples retain the
a href for current link, as without it, people using a screen reader and navigating by links, or via focusable content with the tab key would not come across the currently active link.
For more information about the
aria-current attribute, read
aria-current attribute by Léonie Watson.