top of page
Writer's pictureWeb Coding

How to create a simple nav bar

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

*{
 padding0;
 margin0;
 font-family'Lato'sans-serif;
}

body{
 background-color#2b2d2f
}

nav{
 height5vh;
 displayflex;
 align-itemscenter;
 justify-contentspace-between;
 font-size2vh;
 text-transformcapitalize;
 background-colorblack;
 color#CC99CC;
}

nav p{
 margin-left3%;
}

#links{
 margin-right1.5%;
}

#links a{
 margin-right7px;
 text-decorationnone;
 color#CC99CC;
}

#links a:hover{
 border-bottom1px 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

4 views

コメント


bottom of page