What can be done to improve the accessibility of a breadcrumb menu similar to:
<ul class="breadcrumbs" aria-label="breadcrumb navigation" role="navigation">
<li><a href="~/">Home</a></li>
<li><a href="~/news">News</a></li>
<li class="unavailable"><a href="#">@Model.Title</a></li>
</ul>
Given in this example Home is the site root, News is the first child, and the unavailable class is the current item the /news/article item.
Is there anything that could be done to improve this such as using rel
attributes or aria-level
attributes?
I would avoid the use of aria-level
and use a <ol>
element instead. It is best to avoid using aria attributes wherever a native alternative exists. Using aria adds an extra layer of complexity. Simple HTML is far better and already has semantics that are surfaced to AT. This is the first rule of ARIA.
Borrowing from the WAI-ARIA-Practices document, breadcrumbs would look like something like this:
<nav aria-label="Breadcrumb" class="breadcrumb">
<ol>
<li>
<a href="../../">
WAI-ARIA Authoring Practices 1.1
</a>
</li>
<li>
<a href="../../#aria_ex">
Design Patterns
</a>
</li>
<li>
<a href="../../#breadcrumb">
Breadcrumb Pattern
</a>
</li>
<li>
<a href="./index.html" aria-current="page">
Breadcrumb Example
</a>
</li>
</ol>
</nav>
Some notes:
- Wrapping the breadcrumbs in a
<nav>
element lets screen reader users quickly find and jump to the breadcrumbs. - Using
<ol>
element surfaces an order to screen reader users. - The
<ol>
should be a child of the<nav>
. Some implementations applyrole="nav"
to the<ol>
itself. This is wrong and will override the default<ol>
semantics. aria-current
informs screen reader users that this is the current page. If the last breadcrumb for the current page is not a link, thearia-current
attribute is optional.
Going from using a screen reader and reading this blog post, the rel
attributes won't make a difference to A.T. As for using aria-level
, it works if you put it on the anchor tags. I'd also advise wrapping the list in a nav
element, for semantic purposes and to save the need of putting a navigation role on the list when you don't need to.
I wound up with this markup for what I think is a not-too-bad breadcrumb. Hide the bullets using CSS (I didn't stop to do that I'm afraid) and I'd say its good.
<nav aria-label="breadcrumb" role="navigation">
<ul>
<li><a href="#" aria-level="1">Home</a></li>
<li><a href="#" aria-level="2">News</a></li>
</ul>
</nav>
Hope this helps!
You can use like below
<nav role="navigation" aria-label="breadcrumbs">
<p id="breadcrumblabel">You are here:</p>
<ol id="breadcrumb" aria-labelledby="breadcrumblabel">
<li><a href="index.html" title="Home">Home</a></li>
<li><a href="products.html" title="Menu1">Menu1</a></li>
<li><a href="shoes.html" title="Menu2">Menu2</a></li>
</ol>
</nav>
When searching the Web for a thorough solution on accessible breadcrumbs, @Craig Brett's solution seemed good at first sight. But after reading several sources, aria-level
seems to be misused there (besides a W3C Validation problem, see my comment above).
Therefor I like to propose this approach:
<nav aria-labelledby="bc-title" role="navigation">
<h6 id="bc-title" class="vis-off">You are here:</h6>
<a href="~/" aria-labelledby="bc-level-1">
<span id="bc-level-1" class="vis-off">Homepage Website-Title </span>Home
</a>
<a href="~/news" aria-labelledby="bc-level-2">
<span id="bc-level-2" class="vis-off">Level 2: News </span>News
</a>
<a href="#" aria-disabled="true">@Model.Title</a>
</nav>
In this solution we have an HTML5 sectioning element (nav
), which should have a heading, and *tada* there it is. Class vis-off
signifies an element that is just available to screen readers. With aria-labelledby
I'm telling the screen reader to read that headline.
In contrast to Chris' solution, either the <ul>
or aria-level
is gone.
I'd so or so go for an <ol>
if necessary, because the items are in order. Better leaving it out, otherwise it gets very verbose in many screen readers on every page ("List item 1…"). aria-level
seems to be misused in the solution above in my understanding. It must be child of a role attribute like f.e. role="list"
and that role just signifies not structurally marked-up non-interactive lists.
Maybe a role treeitem
might be more appropriate. IMHO it's overkill.
PS: I'm not using BEM notation here to shorten the ids and classes for readability.
来源:https://stackoverflow.com/questions/25326699/proper-aria-handling-of-breadcrumb-navigation