CSS Navigation Menu✨

 A Nevigation menu (nav bar) is one of the most important parts of any website.  It helps visitors move between pages easily and improves the user experience.

In this article, you will learn how to create a simple, clean navigation menu.

🌟 What you will Learn in This                     Article 

  • What a navigation menu is
  • How to design a simple HTML structure 
  • How to style a nav bar using CSS 

✨What is a navigation menu?

A Nevigation menu is a group of links placed at the top of a website that help users move between pages like Home, Contact, About us etc.

Example:-

Home/About us/Gallery/Contact 

Why Navigation menu are important?

A good CSS Menu

  • Makes your website look professional 

  • Improves users experience

  • Makes readers stay longer on your website 

  • Boosts SEO and page views 

✍️Types of Navigation Menu 

Different websites use different kinds of navigation menu.Here are some of the most common type.

  • Horizontal Menu: This is the most common type. It appears at the top of the website in a straight line.

  • Vertical Sidebar Menu: Used mostly in dashboards, blogs, and admin panels. It appears on the left or right side.

  • Sticky (fixed) Menu: This menu stays at the top even when the user scrolls the page

  • Dropdown Menu: A menu with sub-items that appears when hovering over a link.

  • Hamburger Mobile Menu: The three-line icon used in mobile website to open and close the menu.

Let's try to create a Horizontal menu:

✅Step 1 : create the HTML structure 

<nav class="nav">

  <ul class="menu">

    <li><a href="#">Home</a></li>

    <li><a href="#">About </a></li>

    <li><a href="#">Contact </a></li>

    <li><a href="#">Gallery</a></li>

  </ul>

</nav>


 ✅Step 2 : Apply CSS design

.nav{

  background:teal;

  padding:10px 20px;

  display:flex;

  justify-content:space-between;

  align-items:center;

}

.logo{

  color:white;

  font-size:20px;

  font-weight:bold;

}

.menu{

  list-style:none;

  margin:0;

  padding:0;

  display:flex;

  gap:15px;

}

.menu li a{

  color:white;

  text-decoration:none;

  padding:8px 12px;

  border-radius:5px;

}

Here output is:

 
Let's try to create Vertical Menu:

Crate a HTML structure and apply CSS styles

<html>
<head>
<style type="text/css">
  body
  {
    margin:0px;
  }
  ul{
    list-style:none;
    margin:0px;
    pedding:0px;
    background-color: black;
    width:25%;
    height:100%;
    position: fixed;
  }
  li a
  {
    color:white;
    text-decoration: none;
    padding: 15px 20px;
    display:block;
    text-align:center;
    font-size: 22px;
  }
  .active
  {
    background-color: cyan;
  }
  </style>
  <title></title>
</head>
<body>
  <ul>
    <li><a href="" class="active">Home</a></li>
 <li><a href="">About </a></li>
    <li><a href="">Contact </a></li>
    <li><a href="">Gallery </a></li>
    <li><a href="">Courses </a></li>
  </ul>
</body>
</html>

Here output is:



Frequently Asked Questions (FAQs):

1. What is the best navigation menu for mobile?

A hamburger menu is best for mobile screens.

2. Can I make a menu without javascript?

Yes, simple menus can be done with only CSS, but toggling requires JS.

3. Which CSS property creates horizontal menus?

display:flex;  is most commonly used.

4. How do I center menu items?

Use:- 

justify-content:center;

🎉Conclusion 

A Nevigation menu is a key part of any websites with HTML and CSS,  you can design beautiful, responsive, and user-friendly menus that look great on all devices from horizontal menus to hamburger mobile menus, the possibilities are endless.
With the examples in this guide, you can easily create your own custom navigation menu and use it in your website.





Comments

Popular posts from this blog

WEBSITE DEVELOPMENT USING HTML AND CSS

Introduction to CSS ✍️

Advanced properties of CSS