On this page
A website header has limited room and unusually varied responsibilities. It may contain identity, section links, search, account controls, and a call to action. The solution is not to keep reducing the gaps until everything fits. Decide what the header must communicate at each available width.
Give the header a clear job
Separate global navigation from page-specific actions. A marketing header might prioritize product sections and sign-in, while an application header might emphasize workspace identity and search. Putting every local command into the global bar makes both levels harder to understand.
Use the Flexbox Playground to prototype three groups: identity, navigation, and utilities. Explore how gaps, flexible space, and shrinking affect them. Use realistic link labels rather than identical placeholder words. This exposes crowding before a polished design conceals it.
Define a priority order for what remains visible. The brand link and menu trigger usually survive the compact layout, while secondary navigation moves into an expanded panel. This is not permission to hide essential functionality. Each relocated control still needs a clear destination and label. The WAI disclosure navigation example is a useful behavioral reference for ordinary expandable site navigation.
Group links by visual role
Keep the primary navigation visually cohesive through consistent spacing and type treatment. Utilities such as language selection or account access can form a quieter group. A small spatial separation is often enough; adding a vertical divider between every item creates unnecessary visual noise.
Choose one active-location indicator that survives different surfaces. An underline, filled shape, or edge marker can work if it clearly belongs to one destination. Avoid making the active item look exactly like a pressed button. The header should explain where the visitor is, not suggest a transient interaction.
Reserve strong button styling for an action that deserves it. A header with three filled calls to action and five navigation links has no clear visual center. If account access is routinely used, keep it discoverable even when a sales-oriented action is emphasized.
Measure gaps at realistic widths. A 24-pixel link gap may be comfortable in a wide frame but excessive in a constrained application shell. Adjust the layout mode when the content no longer fits rather than gradually squeezing labels into a brittle arrangement.
Switch layouts at the point of crowding
The following sketch supports a full navigation row and a compact alternative. It does not implement the expanded menu's interaction. In a working component, synchronize the trigger's expanded state and provide the panel behavior required by your chosen pattern.
.site-header {
display: flex;
align-items: center;
gap: 1.5rem;
padding: 1rem;
}
.site-brand { flex: none; }
.site-links {
display: flex;
align-items: center;
gap: 1.25rem;
margin-inline-start: auto;
}
.menu-trigger { display: none; }
@media (max-width: 56rem) {
.site-links { display: none; }
.menu-trigger {
display: inline-flex;
margin-inline-start: auto;
}
}Choose that breakpoint by testing your content, not by treating 56rem as a universal tablet boundary. The MDN flexbox guide explains the underlying sizing behavior. For the outer page edges, coordinate the header with your responsive containers.
Avoid visually reordering links into a sequence that differs from keyboard navigation. Keep the compact arrangement understandable when someone moves through it without seeing the entire row at once.
Design the expanded panel as real content
The compact navigation panel needs its own spacing and hierarchy. Do not simply stack the desktop links with their desktop gaps. Give each item a comfortable interactive area, separate utilities from section links, and show nested destinations with a consistent treatment.
Make the menu trigger understandable in both states. An icon can support the label, but it should not be the only explanation when its meaning is uncertain. Keep the close action easy to find, especially when an expanded panel covers the original trigger location.
Avoid making every expandable item resemble a destination. A disclosure control and a link can coexist, but their visual roles should be clear. If the section name is itself a destination, decide whether it has a separate link rather than inventing a hybrid interaction without explanation.
Consider long navigation labels early. Translation, account names, and product renaming can all increase width. A compact menu should permit wrapping where sensible instead of cutting off the words that distinguish two destinations. Review the panel with enough items to require scrolling, not just the five that fit beautifully in the mockup.
Review sticky behavior and page relationships
A sticky header changes the available reading area. Before choosing it, compare the header height with the smallest viewport height you support. A large brand block plus a second utility row can consume a disproportionate share of a landscape phone screen.
Inspect page anchors and focused controls near the top edge. Content should not disappear behind a persistent bar. MDN's scroll-margin-top reference describes one useful mechanism for offsetting scrolled targets, although it does not replace testing the complete page.
Compare the header against dense content, image-heavy sections, and plain forms. If it overlays imagery, check every expected background rather than approving contrast on one convenient screenshot. Use the Contrast Checker for actual foreground and surface pairs.
Finally, review visual balance at intermediate widths, where many headers fail. The brand should not appear detached while utility controls collide. Record the full and compact arrangements, the collapse condition, active states, and the expanded panel's maximum height. Those decisions make the header reproducible without requiring developers to infer behavior from a single wide-screen composition.
Include the signed-out, signed-in, and unusually long account-name variants in the same review. A header often gains controls after authentication, so approving only the public version gives a misleading picture of available space. Decide which utilities remain in the bar and which enter the account panel. Check that a notification badge does not change the width of its neighboring links. If a promotional announcement sits above the header, evaluate their combined height rather than approving each strip independently in an otherwise empty frame.
Key takeaways
- Give global navigation a narrower job than the entire page.
- Group identity, destinations, and utilities deliberately.
- Switch layouts when content crowds, not at a fashionable device width.
- Design the expanded panel and active states explicitly.
- Test sticky headers against short viewports and scrolled targets.
Reach designers & developers at work
Put your product next to the tools people use every day. One sponsor per placement, no tracking pixels.
Become a sponsor