top of page

How to create a simple nav bar

Writer: Web Coding
Web Coding
Sep 6, 2020
1 min read

Today I will be teaching you how to create a nav bar using only HTML and CSS


HTML

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Document</title>
 <link rel="stylesheet" href="style.css">
 <link href="https://fonts.googleapis.com/css2?family=Lato&display=swap" rel="stylesheet">
</head>
<body>
 <nav>
 <p>Company Name</p>
 <div id="links">
 <a href="">Home</a>
 <a href="">About</a>
 <a href="">Blog</a>
 <a href="">Contact</a>
 </div>
 </nav>
</body>
</html>

CSS

*{
 padding: 0;
 margin: 0;
 font-family: 'Lato', sans-serif;
}

body{
 background-color: #2b2d2f
}

nav{
 height: 5vh;
 display: flex;
 align-items: center;
 justify-content: space-between;
 font-size: 2vh;
 text-transform: capitalize;
 background-color: black;
 color: #CC99CC;
}

nav p{
 margin-left: 3%;
}

#links{
 margin-right: 1.5%;
}

#links a{
 margin-right: 7px;
 text-decoration: none;
 color: #CC99CC;
}

#links a:hover{
 border-bottom: 1px solid #CC99CC;
}

If you found this blog post helpful don’t forget to check out my other projects and if you want more content follow me on


YouTube: https://www.youtube.com/channel/UC2nxqB2usQIS2c8zwVZKWEQ

Instagram: https://www.instagram.com/coding_for_the_web/

Twitter: https://twitter.com/LearnWebCoding

Comments


  • YouTube
  • Instagram

©2020 by Web Coding. Proudly created with Wix.com

bottom of page