How to create: Monospaced navigation bar links

Learn how to create a navigation bar with monospaced navigation links.

Monospaced menu

Try It Yourself

Create a responsive navigation bar

First step - Add HTML:

/* Navigation menu */
<div class="navbar">
  <a class="active" href="#">Home</a>
  <a href="#">Search</a>
  <a href="#">Contact</a>
  <a href="#">Login</a>
</div>

Second step - Add CSS:

/* Set the style for the navigation menu */
.navbar {
  width: 100%;
  background-color: #555;
  overflow: auto;
}
/* Navigation links */
.navbar a {
  float: left;
  padding: 12px;
  color: white;
  text-decoration: none;
  font-size: 17px;
  width: 25%; /* Four equal-width links. If you have two links, use 50%, for three links, use 33.33%, and so on. */
  text-align: center; /* If you want the text to be centered */
}
/* Add background color on mouse hover */
.navbar a:hover {
  background-color: #000;
}
/* Set the style for the current/active link */
.navbar a.active {
  background-color: #04AA6D;
}
/* Add responsiveness - on screens smaller than 500 pixels, stack the navigation links instead of displaying them side by side */
@media screen and (max-width: 500px) {
  .navbar a {
    float: none;
    display: block;
    width: 100%;
    text-align: left; /* If you want the text to be aligned to the left on small screens */
  }
}

Try It Yourself

Iconic monospaced navigation links

Try It Yourself

Related Pages

Tutorial:CSS Navigation Bar