html
  1. html-nav-tag

HTML <nav> Tag

The HTML <nav> tag represents a section of the document meant for navigation links, often with a navigation bar.

Syntax

<nav>
  <ul>
    <li><a href="#home">Home</a></li>
    <li><a href="#about">About</a></li>
    <li><a href="#contact">Contact</a></li>
  </ul>
</nav>

Example

Here is an example of a navigation bar using the <nav> tag:

<nav>
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">About Us</a></li>
    <li><a href="#">Services</a></li>
    <li><a href="#">Contact Us</a></li>
  </ul>
</nav>
Try Playground

The above example produces a navigation bar with four links: Home, About Us, Services, and Contact Us.

Explanation

The <nav> tag is used to define a navigation section of the webpage. Inside this tag, a <ul> (unordered list) is often used to create a list of links to navigate around the website. Each link is represented by an <a> tag with an href attribute to specify the URL.

Use

The <nav> tag should be used for any section of a webpage that is meant for navigation links. This tag is useful in creating consistent navigation menus across a website.

Important Points

  • The <nav> tag should only be used for navigation links.
  • Each navigation link should be represented by an <a> tag with an href attribute to specify the URL.

Summary

The <nav> tag is used to indicate a section of a webpage that contains navigation links. It is useful in creating consistent navigation menus across a website. The <nav> tag should only be used for navigation links and each link should be represented by an <a> tag with an href attribute.

Published on: