The <nav> tag is used in HTML to create navigation sections on a webpage. It helps users and search engines know which links are for moving around the site.
- <nav> usually contains links to main parts of a website, like Home, About, or Contact.
- Links can be written directly or inside an unordered list (<ul>).
- Improves webpage structure, accessibility, and SEO.
- Commonly used in modern websites for clear navigation.
- The <nav> tag contains a set of navigation links for sections like Home, Interview, Languages, Data Structure, and Algorithm.
- The links are separated by vertical bars for clarity.
Syntax:
<nav>
<!-- Your navigation links here -->
</nav>
Note: The <nav> tag also supports the Global Attribute and Event Attributes in HTML.
Using the <nav> Tag
Links within the <nav> tag can either be standalone or structured within an unordered list (<ul>) for better organization. While it’s common to use lists, it’s not a strict requirement.
Styling the <nav> Tag Using CSS:
Apply CSS styling to the <nav> section to enhance its appearance.
- The <nav> tag defines a horizontal navigation menu with section links separated by delimiters.
- CSS styles give the menu a green background, white text, padding, and remove underline from links for a clean, readable look.