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.