The HTML Navigation Element (
<nav>) represents a section of a page that links to other pages or to parts within the page: a section with navigation links.
Here are a few important points to remember about the <nav> element:
<ul> inside the <nav> element to structure the links, because it's easier to style.<nav> in the <header> element is also a common practice but not required.<nav> element. If we have a list of links inside a <footer> tag, then its isn't really necessary to include those links in a <nav> as well.<nav> element in a single page, for example, a main navigation, a utility navigation, and a <footer> navigation.Consider the following example:
<body>
<header class="masthead" role="banner">
<div class="logo">Mastering RWD with HTML5 & CSS3</div>
<div class="search" role="search">
<form>
<label>Search:
<input type="text" class="field">
<button>Search Now!</button>
</label>
</form>
</div>
</header>
<nav class="main-nav" role="navigation">
<ul class="nav-container">
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
</ul>
</nav>
<main class="main-container" role="main">
<article class="article-container flex-container">
<section class="main-content">
<header>
<h1>The <code><main></code> element</h1>
</header>
<p>As per the MDN definition:</p>
<blockquote>
<p>The HTML Main Element (<code><main></code>) represents…</p>
</blockquote>
</section>
<aside class="side-content" role="complementary">
<h2>What Does "Semantic HTML" Mean?</h2>
<p>Semantic markup basically means that we use HTML tags to describe what a specific piece of content is.</p>
</aside>
</article>
<footer class="main-footer" role="contentinfo">
<p>Copyright ©</p>
<ul class="nav-container" role="navigation">
<li><a href="#">Footer Link 1</a></li>
<li><a href="#">Footer Link 2</a></li>
<li><a href="#">Footer Link 3</a></li>
<li><a href="#">Footer Link 4</a></li>
<li><a href="#">Footer Link 5</a></li>
</ul>
</footer>
</main>
</body>