How to Create Header Menu: A Complete Guide with Source Code

how to create Header menu

Introduction

Every professional website needs a clear and organized Header menu. The Header menu serves as the main navigation tool, helping visitors find important pages like Home, About, Services, Blog, and Contact etc. Understanding how to create Header menu is essential for web developers, bloggers, and anyone creating a website. 

you can refer to W3Schools tutorials

In this guide from Skill Mind India, we will cover everything about Header menus from definitions to Header menu and we provide source code examples and WordPress integration. 

What is a Header Menu?

Header menu is the navigation bar displayed at the top of our website. It usually includes links to the most important pages and may also contain dropdowns or submenus for better organization. A well-designed Header menu improves user experience, reduces bounce rates, and makes your website easy to navigate.

Key Features of a Header Menu:

Types of Header Menus

How to Create Header Menu Using HTML and CSS

Creating a Header menu from scratch is easier than it seems. Below is a simple example with Header menu source code.

HTML Code

				
					<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Header Menu Example</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <header>
        <div class="logo">Skill Mind India</div>
        <nav>
            <ul class="menu">
                <li><a href="index.html">Home</a></li>
                <li><a href="about.html">About</a></li>
                <li><a href="services.html">Services</a></li>
                <li><a href="blog.html">Blog</a></li>
                <li><a href="contact.html">Contact</a></li>
            </ul>
        </nav>
    </header>
</body>
</html>

				
			

CSS Code

				
					* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1E90FF;
    padding: 15px 50px;
}

header .logo {
    color: #fff;
    font-size: 24px;
    font-weight: bold;
}

nav ul.menu {
    list-style: none;
    display: flex;
    gap: 20px;
}

nav ul.menu li a {
    color: #fff;
    text-decoration: none;
    font-size: 18px;
    transition: color 0.3s;
}

nav ul.menu li a:hover {
    color: #FFD700;
}

/* Responsive Menu */
@media (max-width: 768px) {
    nav ul.menu {
        flex-direction: column;
        display: none;
    }
}

				
			

Creating a Responsive Header Menu with JavaScript

Modern websites need responsive menus that work on mobile devices. Adding a hamburger menu icon makes your Header menu mobile-friendly.

Responsive HTML + CSS + JS Code

				
					<header>
    <div class="logo">Skill Mind India</div>
    <nav>
        <div class="hamburger" onclick="toggleMenu()">&#9776;</div>
        <ul class="menu" id="menu">
            <li><a href="index.html">Home</a></li>
            <li><a href="about.html">About</a></li>
            <li><a href="services.html">Services</a></li>
            <li><a href="blog.html">Blog</a></li>
            <li><a href="contact.html">Contact</a></li>
        </ul>
    </nav>
</header>

<script>
function toggleMenu() {
    const menu = document.getElementById('menu');
    if (menu.style.display === 'flex') {
        menu.style.display = 'none';
    } else {
        menu.style.display = 'flex';
        menu.style.flexDirection = 'column';
    }
}
</script>

				
			

This approach ensures your website is mobile-optimized, which is essential for Google content monetization and SEO.

How to Create Header Menu in WordPress

WordPress simplifies creating a Header menu without coding. Follow these steps:

  1. Login to WordPress Dashboard
    Navigate to Appearance > Menus.

  2. Create a New Menu
    Click on “Create New Menu,” name it (e.g., Main Menu), and click Create Menu.

  3. Add Menu Items
    Add pages, posts, categories, or custom links, then click “Add to Menu.”

  4. Organize Menu Items
    Drag items to arrange them; use indentation for submenus.

  5. Assign Menu Location
    Set it as the Header menu and save changes.

  6. Preview Your Menu
    Check your website to ensure the Header menu appears correctly and is responsive.

Best Practices for Header Menus

  1. Keep It Simple: Limit to 5–7 main links.

  2. Readable Fonts: Use clear fonts and proper sizes.

  3. Highlight Active Page: Helps users know their current location.

  4. Use Dropdowns Wisely: Only for organized categories.

  5. Mobile Optimization: Use responsive design or plugins.

  6. Test Across Browsers: Ensure consistency on Chrome, Firefox, Safari, etc.

Common Mistakes to Avoid

  • Overcrowded menus with too many links

  • Poor color contrast that affects readability

  • Ignoring mobile optimization

  • Slow-loading header images or animations

Following these tips ensures your Header menu improves user experience and aligns with Google’s monetization guidelines.

Advantages of a Well-Designed Header Menu

  • Improved User Navigation: Visitors easily find what they need.

  • Better SEO: Search engines can crawl your website more efficiently.

  • Increased Page Views: Users spend more time exploring.

  • Professional Appearance: Enhances website credibility.

Header Menu Source Code Repository

The Header menu source code provided in this tutorial can be used in HTML/CSS projects or adapted for WordPress. Skill Mind India encourages customizing colors, fonts, and layout to match your website branding.

Conclusion

A well-structured Header menu is essential for any professional website. From basic HTML/CSS to responsive JavaScript menus and WordPress integration, this guide shows you exactly how to create Header menu and use Header menu source code effectively.

Skill Mind India ensures this tutorial is beginner-friendly, original, and actionable for anyone looking to build a professional navigation system.

Recent Comments
Facebook
Twitter
LinkedIn