Table of contents
No headings in the article.
Hi there, In this blog, we are going to create a simple horizontal navigation bar using simple easy steps.
So let's begin.
Step 1:Create an unordered list.
Firstly we have to create an unordered list of items that we have to display in our bar as follows.
<!DOCTYPE html>
<html>
<body>
<div class="topnav">
<a class="active" href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
</div>
</body>
</html>
Note: We have used href="#" for test links. In a real website, this would be URLs.
Step 1:Add CSS
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.topnav {
overflow: hidden;
background-color: green;
}
.topnav a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color:#83d383;
color: black;
}
.topnav a.active {
background-color: #04AA6D;
color: white;
}
It looks like this: