HTML & CSS

Build a Responsive Navbar

Build a responsive navbar by starting with clear navigation priorities, semantic markup, flexible layout, visible focus states and a mobile menu that stays usable at small widths.

What this workflow solves

Target outcome

A navigation pattern that works on desktop and mobile, keeps links readable and gives keyboard users a clear path through the site.

Work through Responsive navbar

Track each step, focus the current task and copy a starter outline for your project notes or implementation plan.

0% complete
Choose the navigation jobs

A navbar should expose the most important destinations without turning the header into a full sitemap.

  • Keep top-level links short and destination-focused.
  • Move secondary links into the footer or a section navigation.
  • Use one clear product or conversion link if needed.
Starter codeCopy and adapt this outline for the workflow.
<section aria-labelledby="build-responsive-navbar-title">
  <p>Responsive navbar</p>
  <h2 id="build-responsive-navbar-title">Build a Responsive Navbar</h2>
  <p>A navigation pattern that works on desktop and mobile, keeps links readable and gives keyboard users a clear path through the site.</p>
  <ol>
    <li>Choose the navigation jobs</li>
    <li>Build the desktop layout</li>
    <li>Plan the mobile menu</li>
  </ol>
</section>

Preview a navbar pattern

Toggle mobile, CTA and sticky states, then copy the generated starter HTML or CSS.

Brand
FeaturesPricingContact
Generated HTML
<header class="site-header">
  <a class="logo" href="/">Brand</a>
  <nav aria-label="Primary navigation">
    <a href="/features">Features</a>
    <a href="/pricing">Pricing</a>
    <a href="/contact">Contact</a>
  </nav>
  <a class="header-cta" href="/start">Get started</a>
</header>
Generated CSS
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
}

.site-header.sticky {
  position: sticky;
  top: 0;
  backdrop-filter: blur(12px);
}

@media (max-width: 700px) {
  .site-header {
    align-items: stretch;
    flex-direction: column;
  }
}

Work this way

These are the patterns that keep the workflow practical, accessible and easier to maintain.

Keep top-level links short and destination-focused.
Use a nav landmark with descriptive aria-label text.
Use a real button to open and close the menu.
Mark the active section clearly.

Avoid these traps

Starting with visual styling before the semantic structure is clear.
Using fixed widths that create mobile overflow.
Hiding important navigation or content without a usable fallback.

Step-by-step workflow

Follow the steps in order, then use the resource sections when you need a tool, reference or UI pattern.

1

Choose the navigation jobs

A navbar should expose the most important destinations without turning the header into a full sitemap.

  • Keep top-level links short and destination-focused.
  • Move secondary links into the footer or a section navigation.
  • Use one clear product or conversion link if needed.
2

Build the desktop layout

Use semantic links and flexible spacing so the navigation stays stable as labels change.

  • Use a nav landmark with descriptive aria-label text.
  • Align logo, links and actions with flexbox.
  • Avoid fixed widths that cause labels to overlap.
3

Plan the mobile menu

The mobile menu should reveal the same core destinations in a comfortable, tappable layout.

  • Use a real button to open and close the menu.
  • Expose aria-expanded for the toggle state.
  • Stack links with enough tap spacing and visible focus states.
4

Check states before shipping

Navigation quality shows up in hover, active, focus and small-screen states.

  • Mark the active section clearly.
  • Tab through every link and menu control.
  • Test at narrow mobile widths and with longer labels.

Tools, cheatsheets and components

Use these linked DevKitYard sections when the guide moves from planning to doing.

Build navbar presets in ElementYard

Use ElementYard navbar presets when you want to visually customise layout, spacing and header actions.

Open ElementYard

Responsive navbar questions

Should a responsive navbar hide every link behind a menu?

Not always. Keep critical desktop links visible when space allows, then use a mobile menu when the layout would otherwise squeeze or wrap badly.

What is the most important accessibility detail for a mobile nav?

Use a real button with a clear label and aria-expanded state, then make sure every menu link is reachable by keyboard.