We are in the process of implementing (i.e. adding) WAI-ARIA support to the main navigation menu of a web portal. Menu is the one shown here:
Menu is implemented by means of classic <ul>
/ <li>
/ <a>
DOM tree, styled with CSS to look like horizontal tabs.
What is a WAI-ARIA compliant implementation for such a widget?
I've read many parts of most recent WAI-ARIA specs from w3org for a general understanding, taxonomy, and so on. Then I've read about several examples of UI widget implementations. I could not find any example specifically targetd at such a CSS navigation menu. The closest widgets I've always found around are the Menu, the MenuBar, and the TabPanel. Of course I also looked in Free ARIA Community group (where this question was originally posted).
I'd say that none of those widgets exactly match a (CSS) navigation menu. As an example, TabPanel may control some content in the page (--> aria-controls), maybe MenuBar too; but I'm not at all sure that a navigation menu controls content in the page (it controls the next page to show). Without going further, there are some other differences as well. References are at the end of the post. If anyone as better (or more fit) examples of navigation menu, we'd be glad to know about them.
References
WAI-ARIA refers to the Web Accessibility Initiative – Accessible Rich Internet Applications. WAI-ARIA is a technical specification written by the World Wide Web Consortium (W3C). The specification is most commonly used by developers to build interactive website content that is accessible to people with disabilities.
Accessible Rich Internet Applications ( ARIA ) is a set of roles and attributes that define ways to make web content and web applications (especially those developed with JavaScript) more accessible to people with disabilities.
A possible implementation would be:
HTML structure:
<div> <!-- Outer wrapper --> <ul> <!-- Main navigation bar container --> <li> <!-- First-level item without submenu --> <a> <!-- Destination URL --> </a> </li> <li> <!-- First-level item with submenu --> <a> <!-- Destination URL --> </a> <ul> <!-- Second-level menu container --> <li> <!-- Second-level item --> <a> </a> <!-- Destination URL --> </li> </ul> </li> </ul> </div>
Roles:
<div>
<ul>
navigation bar container<ul>
containers<li>
menu items (they are not needed in the exposed accessible menubar structure)<a>
menu itemsProperties:
<a>
menu items having a submenu<a>
menu item" for second-level <ul>
containersStates:
<a>
item; aria-selected="false" on the other <a>
items. That is to enforce the concept “selected <==> current page”<ul>
containers<ul>
containers<ul>
navigation bar container. This is an alternative to working with tabindex<a>
item; tabindex=-1 on the other <a>
items. That is in order to first focus on the current page when tabbing to the navigation bar. It is an alternative to working with aria-activedescendantKeyboard:
Aug/2014: aria-selected Vs menuitem
In reply to @Joshua Muheim comment: now I can see from here, as well as from his reference, that aria-selected
attribute is not allowed for menuitem
role.
As I read from this recent SO answer there are some solutions given the current state of things, and there is a new proposed attribute too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With