HTML Nav Tag

Nav Tag in HTML

The nav tag is used for bringing the navigation links together. It is not compulsory that you have to keep all your links in the nav tag, but the nav tag just defines a set of some major navigation links. This is just used for quick navigation between the web pages.

Have a look at the below example, where we are trying to make use of Nav tag →

<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>Some heading…</title>
</head>
<body>
<nav>
<a href=”#”>Home</a> |
<a href=”#”>Services</a> |
<a href=”#”>Explore</a> |
<a href=”#”>About us</a>
</nav>
</body>
</html>

If we try to open the file in the browser, the output of the above example is going to be something like this –


As you can see, we got some links to navigate around. These are some major navigation links that you would want to provide. We can get these into the nav tag. Basically, we can have many nav tags, and many links as well, but not every link is going to be a part of the navigation set.