Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 sub nav semantics

Tags:

html

nav

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

I have <nav> in the header for the main menu. Down the left of a standard page I have second level nav and down the right third level nav (no, I didn’t design the site). Is there anything I can do HTML5/ARIA wise to differentiate between the 3 menus? Or are they all simple <nav> blocks?

I dont even think I need <aside> in either left or right column as there isnt any additional info apart from these actual menus.

Any thoughts/advice would be much appreciated.

like image 749
Adi Avatar asked May 19 '11 16:05

Adi


People also ask

Is NAV HTML5 semantic element?

It is a semantic element. Common examples of the nav elements are menus, tables, contents, and indexes.

What are HTML5 semantics?

Semantic HTML elements are those that clearly describe their meaning in a human- and machine-readable way. Elements such as <header> , <footer> and <article> are all considered semantic because they accurately describe the purpose of the element and the type of content that is inside them.

What are the new HTML5 semantic elements?

HTML5 provides new semantic elements that allow authors to specifically define aspects of web documents, including <header> , <footer> , <section> , <article> , <figure> and <figcaption> .


1 Answers

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:

<nav role="navigation" aria-labelledby="firstLabel">
  <h2 span id="firstLabel" class="hidden">Main menu</h2>
  <ul/>
</nav>
...
<nav role="navigation" aria-labelledby="secondLabel">
  <h2 span id="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.

like image 152
AlastairC Avatar answered Dec 20 '22 04:12

AlastairC