Skip to content Skip to sidebar Skip to footer

Html5 Sub Nav Semantics

A quick question re: HTML5 nav, specifically that of sub navigation (from a semantic point of view). I have

Solution 1:

This may be an old question, but there is a better answer now:

You can label each navigation section implicitly using headings, and explicitly use WAI-ARIA attributes:

<navrole="navigation"aria-labelledby="firstLabel"><h2spanid="firstLabel"class="hidden">Main menu</h2><ul/></nav>
...
<navrole="navigation"aria-labelledby="secondLabel"><h2spanid="secondLabel"class="hidden">Local pages</h2><ul/></nav>

For user-agents like screenreaders, they can report that as "Local pages, navigation" (although they vary in how it's reported).

Read more on a W3C wiki page on using labelledby.

Solution 2:

I would differentiate between the navigation sections by giving them semantically relevant ids and by placing them in order of importance in the HTML code, along the following lines:

<body><navid="main-navigation"><!-- The main menu goes here --></nav><navid="sub-navigation"><!-- The left hand menu goes here --></nav><navid="leaf-navigation"><!-- The right hand third level menu goes here --></nav><sectionid="content"><!-- Actual page content --></section></body>

Other than that, I see no real need for further differentiation between the sections. The above approach is easy to understand, should be reasonably easy to style and is semantically clear, which is certainly good enough for me.

Post a Comment for "Html5 Sub Nav Semantics"