Falytom logoFALYTOM
Games
ToolsUI ComponentsServicesProductsAbout
LoginSign Up
menu
  1. Home
  2. /Web Development
  3. /Html
  4. /Nav Element
Your Progress0%
0 of 76 completed

Topics

Getting Started

  • What is HTML?
  • How the Web Works
  • Setting Up Your Environment
  • Your First HTML Page

HTML Document Structure

  • The DOCTYPE Declaration
  • The HTML Element
  • The Head Section
  • Meta Tags
  • The Body Element
  • HTML Comments

Text and Formatting

  • Headings (h1-h6)
  • Paragraphs
  • Line Breaks and Horizontal Rules
  • Text Formatting (Bold, Italic, etc.)
  • Quotations and Citations
  • Preformatted Text and Code
  • Subscript and Superscript

Links and Navigation

  • Creating Links
  • Absolute vs Relative URLs
  • Link Targets and Attributes
  • Email and Phone Links
  • Internal Page Links

Images and Media

  • Adding Images
  • Image Attributes
  • Image Formats
  • Figure and Figcaption
  • Responsive Images
  • Audio Elements
  • Video Elements
  • Embedding Content

Lists

  • Unordered Lists
  • Ordered Lists
  • Description Lists
  • Nested Lists

Tables

  • Table Basics
  • Table Headers and Footers
  • Spanning Columns and Rows
  • Table Captions
  • Styling Tables

Forms - Part 1 (Basics)

  • Introduction to Forms
  • Text Input Fields
  • Labels and Placeholders
  • Textarea Element
  • Checkboxes
  • Radio Buttons

Forms - Part 2 (Advanced)

  • Select Dropdowns
  • File Upload Inputs
  • HTML5 Input Types
  • Form Validation
  • Form Buttons
  • Fieldsets and Legends
  • Form Accessibility

Semantic HTML

  • What is Semantic HTML?
  • Header and Footer
  • Nav Element
  • Main and Article
  • Section and Aside
  • Div vs Semantic Elements
  • Time and Mark Elements

HTML5 Features

  • HTML5 Overview
  • Canvas Element
  • SVG in HTML
  • Geolocation API
  • Drag and Drop
  • Local Storage
  • Web Workers

Web Accessibility

  • Introduction to Accessibility
  • ARIA Attributes
  • Keyboard Navigation
  • Alt Text Best Practices
  • Color Contrast and Typography
  • Testing for Accessibility

Best Practices & SEO

  • HTML Best Practices
  • SEO Fundamentals
  • Meta Tags for SEO
  • Structured Data

Nav Element

Navigation containers

The <nav> element represents a section of navigation links. It's used for major navigation blocks like main site menus, table of contents, or page indexes. Using nav helps screen readers and search engines identify navigation areas on your page.

Basic Navigation

The most common use of nav is for the main site navigation menu:

basic-nav.html
<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/about">About</a></li>
    <li><a href="/products">Products</a></li>
    <li><a href="/contact">Contact</a></li>
  </ul>
</nav>

When to Use Nav

Use <nav> for:

  • Main site navigation
  • Table of contents
  • Breadcrumb navigation
  • Pagination

Don't use nav for:

  • Social media links (use footer instead)
  • Tag clouds
  • Single links that aren't part of a navigation section

Multiple Nav Sections

You can have multiple nav elements on a page. Use aria-label to differentiate them:

multiple-nav.html
<!DOCTYPE html>
<html lang="en">
<body>
  <header>
    <!-- Main navigation -->
    <nav aria-label="Main navigation">
      <ul>
        <li><a href="/">Home</a></li>
        <li><a href="/about">About</a></li>
        <li><a href="/blog">Blog</a></li>
      </ul>
    </nav>
  </header>
  
  <main>
    <article>
      <h1>Article Title</h1>
      
      <!-- Table of contents -->
      <nav aria-label="Table of contents">
        <h2>Contents</h2>
        <ul>
          <li><a href="#intro">Introduction</a></li>
          <li><a href="#methods">Methods</a></li>
          <li><a href="#conclusion">Conclusion</a></li>
        </ul>
      </nav>
      
      <p>Article content...</p>
    </article>
  </main>
  
  <footer>
    <!-- Footer navigation -->
    <nav aria-label="Footer navigation">
      <a href="/privacy">Privacy</a>
      <a href="/terms">Terms</a>
      <a href="/sitemap">Sitemap</a>
    </nav>
  </footer>
</body>
</html>

Common Navigation Patterns

Horizontal Menu

horizontal-menu.html
<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/products">Products</a></li>
    <li><a href="/services">Services</a></li>
    <li><a href="/contact">Contact</a></li>
  </ul>
</nav>

<style>
  nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
    padding: 0;
  }
  
  nav a {
    text-decoration: none;
    color: #333;
    padding: 8px 16px;
  }
  
  nav a:hover {
    background-color: #f0f0f0;
    border-radius: 4px;
  }
</style>

Breadcrumb Navigation

breadcrumb.html
<nav aria-label="Breadcrumb">
  <ol>
    <li><a href="/">Home</a></li>
    <li><a href="/products">Products</a></li>
    <li><a href="/products/electronics">Electronics</a></li>
    <li aria-current="page">Laptops</li>
  </ol>
</nav>

<style>
  nav[aria-label="Breadcrumb"] ol {
    list-style: none;
    display: flex;
    gap: 8px;
    padding: 0;
  }
  
  nav[aria-label="Breadcrumb"] li::after {
    content: " / ";
    margin-left: 8px;
  }
  
  nav[aria-label="Breadcrumb"] li:last-child::after {
    content: "";
  }
</style>

Dropdown Menu

dropdown-menu.html
<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li>
      <a href="/products">Products</a>
      <ul>
        <li><a href="/products/software">Software</a></li>
        <li><a href="/products/hardware">Hardware</a></li>
        <li><a href="/products/services">Services</a></li>
      </ul>
    </li>
    <li><a href="/about">About</a></li>
  </ul>
</nav>

Best Practices

Use Lists for Navigation

use-lists.html
<!-- Good: Using lists -->
<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/about">About</a></li>
  </ul>
</nav>

<!-- Acceptable: Simple text links -->
<nav>
  <a href="/">Home</a>
  <a href="/about">About</a>
  <a href="/contact">Contact</a>
</nav>

Label Multiple Navs

label-navs.html
<!-- Good: Clear labels for screen readers -->
<nav aria-label="Main navigation">
  <!-- main menu -->
</nav>

<nav aria-label="Secondary navigation">
  <!-- secondary menu -->
</nav>

<!-- Also good: Using aria-labelledby -->
<h2 id="footer-nav-heading">Site Links</h2>
<nav aria-labelledby="footer-nav-heading">
  <!-- footer links -->
</nav>

Add Skip Links

Help keyboard users skip navigation:

skip-links.html
<a href="#main-content" class="skip-link">Skip to main content</a>

<nav>
  <!-- navigation links -->
</nav>

<main id="main-content">
  <!-- page content -->
</main>

<style>
  .skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
  }
  
  .skip-link:focus {
    top: 0;
  }
</style>

Common Mistakes

mistakes.html
<!-- Bad: Using nav for everything -->
<nav>
  <a href="#">Twitter</a>
  <a href="#">Facebook</a>
</nav>

<!-- Better: Social links in footer -->
<footer>
  <p>Follow us:</p>
  <a href="#">Twitter</a>
  <a href="#">Facebook</a>
</footer>

<!-- Bad: Wrapping single links -->
<nav>
  <a href="/login">Login</a>
</nav>

<!-- Better: Single link doesn't need nav -->
<a href="/login">Login</a>

Key Takeaways

  • Use <nav> for major navigation sections
  • Helps screen readers identify navigation areas
  • Use lists (ul/ol) inside nav for better structure
  • You can have multiple nav elements on a page
  • Use aria-label to distinguish multiple navs
  • Don't use nav for social links or single links
  • Consider adding skip links for accessibility

What's Next?

Now that you understand the nav element, the next lesson will cover<main> and <article> elements, which help structure the primary content of your pages.

Know someone who'd find this guide helpful? Please share!

Previous
Header and Footer
Next
Main and Article

Never Miss a New HTML Tutorial

Join 1,000+ developers learning HTML step-by-step. Get new tutorials, tips, and exclusive resources delivered to your inbox - completely FREE.

You might also like

UI Components

Ready-made components for your projects

Developer Tools

Boost productivity with handy generators

HTML Game

Learn HTML concepts through interactive gameplay

Join Our Web Development Training Program

Master frontend & backend development with hands-on projects.

Menu

Topics

Getting Started

  • What is HTML?
  • How the Web Works
  • Setting Up Your Environment
  • Your First HTML Page

HTML Document Structure

  • The DOCTYPE Declaration
  • The HTML Element
  • The Head Section
  • Meta Tags
  • The Body Element
  • HTML Comments

Text and Formatting

  • Headings (h1-h6)
  • Paragraphs
  • Line Breaks and Horizontal Rules
  • Text Formatting (Bold, Italic, etc.)
  • Quotations and Citations
  • Preformatted Text and Code
  • Subscript and Superscript

Links and Navigation

  • Creating Links
  • Absolute vs Relative URLs
  • Link Targets and Attributes
  • Email and Phone Links
  • Internal Page Links

Images and Media

  • Adding Images
  • Image Attributes
  • Image Formats
  • Figure and Figcaption
  • Responsive Images
  • Audio Elements
  • Video Elements
  • Embedding Content

Lists

  • Unordered Lists
  • Ordered Lists
  • Description Lists
  • Nested Lists

Tables

  • Table Basics
  • Table Headers and Footers
  • Spanning Columns and Rows
  • Table Captions
  • Styling Tables

Forms - Part 1 (Basics)

  • Introduction to Forms
  • Text Input Fields
  • Labels and Placeholders
  • Textarea Element
  • Checkboxes
  • Radio Buttons

Forms - Part 2 (Advanced)

  • Select Dropdowns
  • File Upload Inputs
  • HTML5 Input Types
  • Form Validation
  • Form Buttons
  • Fieldsets and Legends
  • Form Accessibility

Semantic HTML

  • What is Semantic HTML?
  • Header and Footer
  • Nav Element
  • Main and Article
  • Section and Aside
  • Div vs Semantic Elements
  • Time and Mark Elements

HTML5 Features

  • HTML5 Overview
  • Canvas Element
  • SVG in HTML
  • Geolocation API
  • Drag and Drop
  • Local Storage
  • Web Workers

Web Accessibility

  • Introduction to Accessibility
  • ARIA Attributes
  • Keyboard Navigation
  • Alt Text Best Practices
  • Color Contrast and Typography
  • Testing for Accessibility

Best Practices & SEO

  • HTML Best Practices
  • SEO Fundamentals
  • Meta Tags for SEO
  • Structured Data
Falytom logoFALYTOM

Learn technologies like HTML, CSS, JavaScript, React, NodeJS and more through interactive games, tutorials, components and free tools. Transform your businesses with AI chatbots, SEO-optimized websites, and professional development services.

© 2025 Tomilola Group
  • Facebook logo
  • Twitter logo
  • Instagram logo
  • LinkedIn logo
  • GitHub logo
  • YouTube logo