Chapter 11: Top Navigation

How to create a good Top Navigation bar (also called navbar, header navigation, top bar, main menu).

We’ll go through different common styles and real-world patterns that are actually used in 2025–2026 websites and web applications.

What makes a good top navigation bar?

Before we write any code, let’s agree on the most important goals:

  1. Clear hierarchy — logo → main links → secondary actions (search, login, cart, profile)
  2. Easy to scan — users should understand where they are and where they can go in 1–2 seconds
  3. Good spacing & touch targets — especially on mobile
  4. Responsive behavior — collapses gracefully on small screens
  5. Visual feedback — hover, active page, mobile menu open/close
  6. Accessibility — keyboard navigation, screen reader support
  7. Performance — doesn’t slow down the page

Most common patterns in 2025–2026

Pattern Best for Mobile behavior Examples you know
Classic centered logo + links Corporate, blogs, marketing sites Hamburger menu Most company websites
Logo left + links center + CTA right SaaS products, tools, dashboards Hamburger or bottom tab bar Notion, Linear, Figma, Stripe
Logo left + minimal links + right icons E-commerce, apps Hamburger + bottom bar sometimes Amazon, Flipkart, Medium
Full-width with mega menu Large sites with many categories Accordion or full-screen overlay Nike, Apple, Samsung
Sticky + shrinking on scroll Long content pages Stays visible Many modern marketing sites

Let’s build the most common and versatile version first — then we’ll look at variations.

Pattern 1 – Modern Classic Top Navigation (very widely used)

HTML Structure

HTML

CSS – Desktop + Mobile

CSS

JavaScript – Mobile menu toggle

JavaScript

Add this CSS for nice X animation:

CSS

Quick variations you should know

1. Shrinking header on scroll (very modern look)

CSS

JavaScript:

2. With search in center (common in SaaS)

HTML

3. Mega menu on hover (for categories)

We usually show a big dropdown panel when hovering “Products” or “Solutions”.

Summary – What to decide when building a top nav

Question Common choice 2025–2026
Logo left or center? Left (almost always)
How many main links? 3–6 (more → dropdown)
Sticky or not? Sticky in most cases
Hamburger on mobile? Yes (from ~1024px)
CTA button? Yes — bright color
Search? Icon or full field
Icons on right? Cart, profile, notifications, search

Would you like to go much deeper into any of these variations?

Examples:

  • Mega menu (dropdown with columns and images)
  • Centered logo style
  • Transparent header over hero section
  • Bottom navigation bar for mobile-first apps
  • Dashboard-style sidebar + top bar combo
  • Animated underline on active link
  • Dark mode navbar

Just tell me which direction you want — I’ll explain it with complete code, slowly and clearly. 😊

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *