HTML nav
Created By: chatGPT
HTML Navigation is crucial for creating a user-friendly web experience. The
<nav>
element is designed to contain navigation links, making it easier for users to find their way around your site. Below is a simple example of how to implement a navigation bar using HTML and some basic CSS for styling.<nav>
<ul>
<li><a href="home.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="services.html">Services</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
In the example above, we create a navigation list using an unordered list (
<ul>
). Each navigation item is represented by a list item (<li>
) containing an anchor tag (<a>
). This structure helps in defining clear navigation paths for users.<style>
nav {
background-color: #333;
color: white;
padding: 15px;
}
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
}
nav ul li {
display: inline;
margin-right: 20px;
}
nav ul li a {
color: white;
text-decoration: none;
}
nav ul li a:hover {
text-decoration: underline;
}
</style>
The CSS styles provided give the navigation bar a dark background and white text, with horizontal spacing between the links. The hover effect underlines the link when a user hovers over it, creating a better user experience.
<body>
<nav>
<ul>
<li><a href="home.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="services.html">Services</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
</body>