HTML nav tag

The HTML nav tag is used to define a section of the HTML document that contains navigation links. This tag is typically used in the header or footer of a website.

The nav tag is a semantic element that helps search engines and screen readers to understand the structure of the web page.


The nav tag is an example of a self-closing tag in HTML. It has no closing tag.

Here is the syntax for the nav tag:

1<nav> 2 <a href="#">Link 1</a> 3 <a href="#">Link 2</a> 4 <a href="#">Link 3</a> 5</nav>


Here is an example of how to use the nav tag in an HTML document:

1<!DOCTYPE html> 2<html> 3 <head> 4 <title>My Website</title> 5 </head> 6 <body> 7 <header> 8 <nav> 9 <a href="#">Home</a> 10 <a href="#">About</a> 11 <a href="#">Contact</a> 12 </nav> 13 </header> 14 <main> 15 <h1>Welcome to my website</h1> 16 <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> 17 </main> 18 <footer> 19 <nav> 20 <a href="#">Privacy Policy</a> 21 <a href="#">Terms of Use</a> 22 <a href="#">Copyright</a> 23 </nav> 24 </footer> 25 </body> 26</html>

In this example, the nav tag is used twice: once in the header and once in the footer of the webpage. Each nav tag contains a list of links that allow users to navigate to different parts of the website.