nav role=navigation

Artem Svirskyi picture Artem Svirskyi · Feb 16, 2013 · Viewed 34.1k times · Source

I'm a little confused with roles. If I have in my page a navigation that is enclosed in a nav element and specify a role="navigation".

<nav role="navigation">
    ...
</nav>

Isn't it already semantically explicit that the nav section is navigation?

Or if I have some other navigation sections on my page, and specify role for only one of them, this section becomes the most important on a page? And those without role="navigation" just boring navigations?

Answer

Mike picture Mike · Feb 16, 2013

It is true that most modern browsers/technologies recognise the HTML5 <nav> element as navigation and give it the same attention. But explicitly setting the role="navigation" attribute just makes sure that a lot more technologies can pick it up.

For example screen-readers and other technologies for users with disabilities are very rarely fully standards compliant (especially if they have to work all the way back to IE6 or lower!) so adding the role attributes explicitly always ensures that you cover all your bases for the most users possible.

Also (and this is just a guess) some of the lesser known search engines may not fully recognise HTML5 yet, so adding these roles should help with the sites crawl-ability.