Creating a Hoverable Navigation Menu Using HTML and CSS

Creating a navigation menu with hover effect is a common design pattern used in web development to enhance user experience and provide visual feedback. This guide will walk you through the steps of creating a simple and stylish navigation menu with hover effect using HTML and CSS .

Key Points

  1. HTML Structure

  2. Basic Styling

  3. Hover Effects

Other Beautiful Navebar

  1. HTML Structure

  2. <nav class="navbar"> : Defines the navigation container with a class for styling.

    <ul class="menu"> : Creates a list for the menu items.

    <li> <a href="#section"> : Each list item contains a link to different sections of the page.

  3. CSS Styling

  4. Reset Styles : Remove default margins and paddings to start with a clean slate.

    Navebar Styling : Apply a background color to the navigation bar and clear floats to handle layout.

    Menu List Styling : Remove bullets and float list items horizontally.

    Link Styling : Style link to appeare as block element with padding and set text color and alignment.

    Hover Effecct : Change the background color of the link on hover.

Output


output17
HTML
<!DOCTYPE html>
  <html lang="en">
    <head>
      <meta charset="UTF-8">
        <meta name="viewport" content ="width=device-width, initial-scale=1.0">
        <title>Simple Hover Menu Bar </title>
          <link rel="stylesheet" href="styles.css"/>
    </head>
  <body>
       <nav class="navbar">
         <ul class="menu">
           <li><a href="#home">Home</a></li>
           <li><a href="#about">About</a></li>
           <li><a href="#services">Services</a></li>
           <li><a href="#contact">Contact</a></li>
         </ul>
       </nav>
         <h1>Welcome to our Website </h1>
          <p>This is a sample page of responsive navbar</p>
   </body>
  </html>
CSS
/*default margins and paddings */
   body, ul {
margin: 0;
padding: 0;
   }
/* Style the navbar */
   .navbar {
background-color: #333;
overflow: hidden;
   }
/*Style the menu items */
   .menu {
   list-style-type: none;
    }
   .menu li {
   float: left;
   }
   .menu li a {
   display: block;
   color: white;
   text-align: center;
   padding: 14px 20px;
   text-decoration: none;
   }
/* Change color on hover */
   .menu li a: hover {
   background-color: #575757;
}



BrodSchool

Jagatpur,
Raebareli 229402, UP,  India
Amresh Kumar (Founder)
Phone: +91 9198 26 3500
Email: suportucracker@gmail.com