Coding Now – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 9667708830
Back to HTML Notes
Topic #803

The nav Element

The <nav> element wraps a block of major navigation links — not every group of links on a page needs one.

Syntax & Example

<nav aria-label="Main navigation">
    <ul>
        <li><a href="/">Home</a></li>
        <li><a href="/cources">Courses</a></li>
        <li><a href="/notes">Notes</a></li>
    </ul>
</nav>

Multiple nav Elements Need Labels

<nav aria-label="Main navigation">...</nav>

<footer>
    <nav aria-label="Footer navigation">
        <a href="/privacy-policy">Privacy Policy</a>
        <a href="/terms-and-conditions">Terms</a>
    </nav>
</footer>

If a page has more than one <nav>, an aria-label lets screen reader users tell them apart when jumping between navigation landmarks — otherwise they just hear "navigation" twice with no way to distinguish them. See aria-label.

When NOT to Use nav

Not every list of links is a <nav>. A handful of tags at the bottom of a blog post, or a single "read more" link, don't need one — reserve it for genuinely significant navigation blocks (primary menu, table of contents, pagination, footer links).

Practical Use Case

Primary site navigation, breadcrumbs, pagination controls, and a table of contents are all legitimate uses of <nav>.

Common Mistakes

  • Wrapping every single link or link group in <nav> — overuse dilutes its value as a landmark
  • Multiple <nav> elements with no distinguishing aria-label, making them indistinguishable to screen reader users

Interview Relevance

"Should every group of links be wrapped in nav?" — a good question to test whether a candidate understands semantic HTML as meaningful markup, not decoration to sprinkle everywhere.

Practice Question

Build a page footer with two distinct link groups (legal links, social links) using <nav> correctly with distinguishing labels.

Related HTML Notes

Want to go beyond the notes?

Join CodingNow's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →