A Beginner's Guide on How to Create a  Navbar in CSS

A navigation bar is a part of a graphical user interface that contains a group of links that lead to different pages on the website. It allows the user to find exactly what they are looking for in no time. In this article, you will understand and learn to create a navigation bar using HTML and CSS.


In this article on navbar in CSS, We will start by creating two files. Save one file as .html extension and another one with .css extension.

Let’s start with our HTML file. We will create five elements in our navbar. Create a ul tag and place five li tags inside the ul tag as you can see below in the code. We will further create sub-sections inside the ‘about’ and ‘contacts’ section. 

UL expands as unordered list, and LI as list items.


Want a Top Software Development Job? Start Here!

Full Stack Developer - MERN StackExplore Program
Want a Top Software Development Job? Start Here!

CSS Code

Next step to creating the navbar in CSS  is to style our elements using CSS code. Open the CSS file. We will start with the elements inside the whole body tag. We will set a background image. We have a file named tech.jpg, which is in the same folder as the HTML and CSS file. We will set the background-size to cover so that it fits the entire screen.

The hover property is used to change the style of the elements when the cursor hovers over that particular element.


Final Output

Our navigation bar is ready.



Creating a navigation bar can be a tricky task if you do not structure your navigation bar properly. In this tutorial, we learned how to create a navigation bar using just HTML and CSS. 

Enroll yourself in the Simplilearn Post Graduate Program in Full Stack Web Development course that will ensure expertise in several relevant topics such as Navbar in CSS and better job prospects. 

If you have any questions or feedback regarding our Navbar in CSS article, let us know in the comments section. Our experts will get back to you as soon as possible.

About the Author

Aryan GuptaAryan Gupta

Aryan is a tech enthusiast who likes to stay updated about trending technologies of today. He is passionate about all things technology, a keen researcher, and writes to inspire. Aside from technology, he is an active football player and a keen enthusiast of the game.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.