Sub topic 3
Choosing a primary navigation pattern
This chapter assumes you can write basic HTML and CSS, you know how lists and links work, and you have read the earlier chapters on information architecture and navigation labels. You should already have a list of your site's top-level sections and a label for each. Here you decide how to present them.
What a primary navigation pattern is
A primary navigation pattern is the way a site shows its top-level sections on every page. The same content can be shown as a plain row of links, a row with dropdowns, a large panel of grouped links (a mega menu), a vertical sidebar, or a menu hidden behind a button.
The pattern is a separate choice from the information architecture. A badly organized site gets no better from a fancier menu. A well organized site can still be hard to use if the pattern doesn't fit its size and its users' habits.
The inputs to the decision
Three facts from your earlier work drive the choice.
- Number of top-level items. Count the sections that must be reachable from every page. Users scan about five to seven items easily. Past roughly nine, a flat row gets crowded.
- Depth and breadth below the top level. Do the sections have a few children each, or dozens grouped into categories?
- How people arrive. Visitors who land from search on a deep page need orientation. Visitors who return daily need speed.
Also consider the device. A pattern that works with a mouse can fail on a phone, where there is no hover and fingers need larger targets.
The main patterns
| Pattern | Best for | Typical size | Main risk |
|---|---|---|---|
| Simple horizontal list | Small sites, marketing sites, portfolios | 3 to 7 top-level items, no children | Runs out of room as the site grows |
| Horizontal bar with dropdowns | Mid-size sites with a few children per section | 5 to 8 items, 3 to 8 children each | Hover-only menus, small targets, hidden content |
| Mega menu | Large catalogs, enterprise, e-commerce, documentation hubs | Many children, often in groups | Heavy markup, accessibility pitfalls, overwhelm |
| Vertical sidebar | Documentation, dashboards, apps with many sections | Dozens of items, often nested | Takes horizontal space, needs a collapsed state on small screens |
| Hamburger or menu button | Small screens, or very minimal designs | Any | Hides navigation, which lowers discoverability on desktop |
Each pattern is discussed below with its trade-offs.
Simple horizontal list
Use this whenever it fits. Every destination is visible and needs no interaction to find. It is also the easiest to make accessible, because it is just a list of links.
If your site has seven sections and no second level, you don't need anything else. Resist adding dropdowns just because other sites have them.
Dropdowns
A dropdown hides child links behind a parent item. It trades visibility for space. This works when users already know which parent holds what they want, and it fails when they have to open every menu to find out.
Two rules keep dropdowns usable:
- The parent should still lead somewhere useful, or be a button that clearly opens a menu. Don't make an item that is both a link and a menu trigger without a clear second control, because keyboard and touch users can't tell which action they will get.
- Keep the list short. A dropdown with 20 items is a mega menu without the layout.
Later chapters cover the correct disclosure markup. For now, the point is that every dropdown needs a click or keyboard path, not only hover.
Mega menus
A mega menu is a large panel that shows many links at once, usually grouped under headings. It suits sites where users browse categories and need to see the range of choices before picking one. Chapter 10 covers when this is the right choice, and the following chapters cover layout and interaction. Treat it as a pattern you earn by having enough content, not as a default.
Sidebars
A vertical navigation scales better than a horizontal bar because a page can be long and a screen can't be wide. It is common in documentation and applications. It lets you show nesting with indentation and mark the current section. The cost is page width, so on narrow screens it usually collapses into a button-triggered panel.
The menu button
On small screens, a button that opens the navigation is often the only practical choice. On wide screens it hides links that could be visible, so avoid it there unless the site is intentionally minimal. A common approach is to show the full navigation on wide screens and switch to a button below a breakpoint. Chapter 8 covers that switch and touch targets.
A decision flow
The diagram below turns the inputs into a first guess. It is a starting point. Test the result with real tasks.
Putting the choice into markup
Whatever pattern you pick, the underlying structure is the same: a nav landmark that contains a list of links. The pattern changes the presentation and the amount of JavaScript, not the base. Here is the simplest pattern, a horizontal list, using only CSS Flexbox.
<nav aria-label="Primary">
<ul class="nav-list">
<li><a href="/">Home</a></li>
<li><a href="/products">Products</a></li>
<li><a href="/pricing">Pricing</a></li>
<li><a href="/support">Support</a></li>
</ul>
</nav>.nav-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem 1.5rem;
margin: 0;
padding: 0;
list-style: none;
}
.nav-list a {
display: inline-block;
padding: 0.75rem 0.5rem;
}flex-wrap: wrap is a deliberate safety net. If a label gets longer after translation or a new item is added, the links move to a second line instead of overflowing the screen. The padding on the links enlarges the clickable area without changing the layout much. The next chapter covers the markup in detail, including labels, landmarks, and the skip link.
Common errors
- Choosing by appearance. Teams copy a competitor's mega menu even though their site has twelve pages. Start from your item count and content depth.
- Hover-only reveal. A menu that opens only on hover can't be used on touch screens and is difficult with a keyboard. Hover can be an enhancement, never the only way in.
- Hiding everything on desktop. A hamburger icon on a wide screen saves little space and costs discoverability.
- Too many top-level items. If the bar needs more than about nine entries, go back to the information architecture and group items before reaching for a bigger menu.
- Inconsistent placement. Moving the navigation between pages makes users relearn it. The primary navigation should appear in the same place on every page.
- Making the pattern do the job of the labels. A mega menu with vague labels is still vague. Fix wording first.
Verifying your choice
Before building, run a quick check using the tasks from your information architecture work. Pick three common user tasks, such as "find the price of the basic plan." For each one, count the interactions needed from any page: how many clicks, taps, or key presses. If a pattern needs more than two interactions for a frequent task, reconsider it. Then check the same tasks on a phone-sized screen.
Exercise
A 6-page portfolio site has the sections Home, Work, About, Writing, Contact, and Resume. None of them has child pages. Which pattern should it use, and why would a mega menu be a poor choice?
Show answer
Use a simple horizontal list, because six top-level items with no children fit easily and every link is visible without interaction. A mega menu would add markup, JavaScript, and accessibility risk to show content that doesn't exist, and it would hide links that could be visible.
Exercise
A team builds a dropdown that opens only on mouse hover and uses the parent item as a link to its landing page. Name two problems and one fix.
Show answer
Touch users can't hover, and keyboard users can't open the menu, so child links are unreachable. A parent that is both a link and a trigger is also ambiguous, because activating it can't both navigate and open the menu. Fix: make the trigger a separate button that toggles the menu on click and Enter or Space, and place the landing page link inside the menu or beside the button.