Menu

How TO – Bottom Border Nav Links


Previous


Next

Learn how to create bottom bordered (underline) navigation links with CSS.


Bottom Border Nav Links

Home     News     Contact

Create A Navigation Menu

Step 1) Add HTML:

Example

<div class=”topnav”>
  <a href=”#home” class=”active”>Home</a>
  <a href=”#news”>News</a>
  <a href=”#contact”>Contact</a>
</div>

Step 2) Add CSS:

Example

<!DOCTYPE html>
<html>
<head>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<style>
body {margin:0;}

.topnav {
overflow: hidden;
background-color: #f1f1f1;
}

.topnav a {
float: left;
display: block;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
border-bottom: 3px solid transparent;
}

.topnav a:hover {
border-bottom: 3px solid red;
}

.topnav a.active {
border-bottom: 3px solid red;
}
</style>
</head>
<body>

<div>
<a href=”#home”>Home</a>
<a href=”#news”>News</a>
<a href=”#contact”>Contact</a>
</div>

<div style=”padding-left:16px”>
<h2>Border Links</h2>
<p>Hover over the links.</p>
</div>

</body>
</html>

Tip: To create mobile-friendly, responsive navigation bars, read our tutorial.

Tip: Learn more about navigation bars.


Previous


Next

Scroll to Top