navigation
Example
<nav role="navigation">
<a href="/">Home</a>
</nav>
<nav role="navigation">
<a href="/terms">Terms</a>
</nav><nav aria-label="Main">
<a href="/" aria-current="page">Home</a>
</nav>
<nav aria-label="Footer">
<a href="/terms">Terms</a>
</nav>Native <nav> needs no role, and unique labels let users tell the landmarks apart.
Common mistakes
- Wrapping every group of links in
<nav>, so the landmark list is noisy. - Labels like 'Main navigation', read as 'Main navigation navigation'.
Key points
- Navigation uses
<nav>without a redundantrole="navigation". - Each
<nav>has a uniquearia-labelwhen there is more than one. - Labels do not include the word 'navigation', since screen readers already say it.
- The current page link has
aria-current="page".
Interview questions
Should every list of links be in a <nav>?
<nav>?No. Use <nav> for major navigation blocks only, like the main menu or breadcrumbs.
Should a <nav> contain a <ul>?
<nav> contain a <ul>?It is common and helpful, since screen readers announce the number of links.