Sub topic 1
Why desktop navigation fails on phones
A desktop navigation bar is a row of links across the top of the page, often with dropdown menus that open on hover. It works because it assumes a wide screen, a precise mouse pointer, and a user who can reach the top of the display. A phone breaks all three assumptions. This chapter names each broken assumption and shows how to measure it. Later chapters build the three patterns that answer them: the hamburger menu, the bottom tab bar, and the priority menu.
Prerequisites
This chapter assumes you already know:
- Basic HTML structure and semantic elements such as
header,nav,ul, anda. - CSS layout with flexbox, and how a media query applies rules at certain screen widths.
- Basic JavaScript: selecting elements with
querySelectorand reading values from them.
You do not need to know ARIA yet. It is introduced when the hamburger menu is built. You will need a desktop browser with developer tools. A real phone is useful but optional for this chapter.
What a desktop navigation assumes
Think of a typical marketing site header. It has a logo on the left and six to eight links in a row. One or two of those links open a dropdown when the pointer hovers over them. The whole bar is about 1000 to 1200 pixels wide, sits at the top of the page, and the links are small text with a few pixels of padding.
Each part of that design relies on an assumption:
| Desktop assumption | What it relies on | What a phone provides instead |
|---|---|---|
| All links fit side by side | A viewport of 1000 CSS pixels or more | A viewport of roughly 320 to 430 CSS pixels in portrait |
| Hovering reveals submenus | A pointer that can rest over an element without clicking | A finger that either touches or does not |
| Small links are clickable | A cursor accurate to about one pixel | A fingertip covering roughly 40 to 60 pixels |
| The top of the page is easy to reach | A user who moves a mouse anywhere on screen in a moment | A thumb that reaches the lower part of the screen comfortably |
A CSS pixel is the unit that layout and media queries use. It is not always a physical device pixel, because high-density phone screens pack several device pixels into one CSS pixel. That is why a phone with a 1170-pixel-wide physical display can still be about 390 CSS pixels wide.
Constraint 1: Width
A row of links needs a total width equal to the sum of each label plus its padding. Eight links averaging 90 pixels each need more than 700 pixels before you add a logo. On a 360-pixel viewport the row cannot fit. The browser then does one of three things, and all of them are bad:
- The row wraps onto several lines. The header grows tall and pushes the content down the screen.
- The row overflows the viewport. Links are cut off, and the page may gain a horizontal scrollbar. Users often never notice the hidden links.
- The text shrinks. This happens when a page has no viewport meta tag and the browser lays the page out at a desktop width and scales it down. Everything becomes unreadable without zooming.
Width is also the only one of the four constraints that changes continuously. A tablet, a phone in landscape, a narrow desktop window, and a browser at 200% zoom all produce intermediate widths. Navigation should therefore respond to the space available, not to a single "mobile" mode. This is the reason the priority menu exists.
Constraint 2: Touch is not a mouse
Touch input differs from mouse input in three ways that matter for navigation.
Precision
A mouse pointer is a single point. A finger is a pad, and users cannot see what is under it while touching. Guidelines for target size reflect this:
- WCAG 2.2 success criterion 2.5.8 (level AA) sets a minimum target size of 24 by 24 CSS pixels, with some exceptions.
- WCAG 2.5.5 (level AAA) recommends 44 by 44 CSS pixels.
- Apple's Human Interface Guidelines recommend 44 points, and Material Design recommends 48 density-independent pixels.
This tutorial uses 48 pixels as its working minimum for primary controls. Spacing matters as well as size. Two 44-pixel targets with no gap between them still cause mis-taps, because a finger lands imprecisely at the edge.
No hover
A touchscreen cannot report a finger that is near the screen but not touching it. Mobile browsers emulate hover to keep old sites working. On the first tap of an element with a :hover rule, the browser may apply the hover state and not follow the link. A second tap then activates it. This leads to two kinds of failure:
- A dropdown that opens only on
:hovermay open and stay open ("sticky hover") until the user taps elsewhere, or may not open at all. - A top-level link that is also a dropdown trigger asks the user to tap twice, with no sign of why.
Keyboard users have the same problem, because they also cannot hover. A navigation that works only on hover fails on phones and on keyboards, for the same reason.
You can limit hover styles to devices that really have hover with a media feature:
/* Applies only where the primary input can hover and is precise */
@media (hover: hover) and (pointer: fine) {
.nav-item:hover > .submenu {
display: block;
}
}This is a useful guard, but it is not a design. Hybrid devices such as laptops with touchscreens report a fine pointer and can also receive touch. Treat the media feature as a fallback, and make every submenu reachable by a click, tap, or key press.
Gestures compete with navigation
On a phone the edges of the screen belong partly to the operating system. Swiping from the left edge may mean "back". Swiping up from the bottom may mean "go home". Browser toolbars appear and disappear as the page scrolls, which changes the visible height. A navigation element placed at the very bottom edge needs padding for the device's safe area, which a later chapter covers with the tab bar.
Constraint 3: Thumb reach
Phones have grown, while hands have not. Many people hold a phone in one hand and use the thumb on the screen. The thumb sweeps an arc. The lower middle of the screen is easy to reach. The top corner on the opposite side of the thumb is hard to reach, and may need a shift of grip.
Desktop navigation puts its controls in the top corner, which is the least comfortable place on a large phone. This does not make the top wrong. Content and page titles belong at the top. It does mean that frequent actions benefit from placement lower on the screen.
Reach is a matter of comfort and speed, not of ability. It also varies:
- Left-handed and right-handed users have mirrored reach zones.
- Some users hold the phone with two hands, and some use it cradled in one hand and tapped with the other.
- Users with limited dexterity may rely on assistive technologies that bypass touch reach altogether.
Because of this variation, do not rely on thumb position as the only way to reach a control. Use it to decide where the most frequent actions go, and keep everything else reachable in a predictable place.
Constraint 4: Context and attention
The last constraint is less about hardware and more about how phones are used.
- Vertical space is scarce. On a phone in portrait, the browser toolbar, the status bar, and a fixed header can together use a quarter of the height. A tall navigation bar that stays fixed to the top competes with the content for what remains.
- Sessions are short and goal-driven. Visitors on phones often want one thing: find a store, check an order, read an article. A navigation that shows every section equally slows them down.
- Attention is divided. People use phones while walking or waiting, so controls need to be obvious and forgiving of mistakes.
- Connections vary. Navigation that depends on heavy JavaScript to appear leaves the user without any links if the script fails or is slow. Start from working HTML links and enhance from there.
Reproducing the failure
The best way to understand these constraints is to see them. This page is a typical desktop navigation with eight links and a hover-only dropdown. Save it as desktop-nav.html.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Desktop navigation demo</title>
<style>
body { font-family: sans-serif; margin: 0; }
header { display: flex; align-items: center; padding: 0 1rem; background: #eee; }
.logo { font-weight: bold; margin-right: 2rem; }
nav ul { display: flex; list-style: none; margin: 0; padding: 0; }
nav li { position: relative; }
nav a { display: block; padding: 4px 8px; color: #123; text-decoration: none; white-space: nowrap; }
.submenu { display: none; position: absolute; top: 100%; left: 0; background: #fff; padding: 0; list-style: none; }
.has-submenu:hover .submenu { display: block; }
</style>
</head>
<body>
<header>
<a class="logo" href="/">Acme Outdoor</a>
<nav aria-label="Main">
<ul>
<li class="has-submenu">
<a href="/products">Products</a>
<ul class="submenu">
<li><a href="/products/tents">Tents</a></li>
<li><a href="/products/boots">Boots</a></li>
</ul>
</li>
<li><a href="/pricing">Pricing</a></li>
<li><a href="/guides">Guides</a></li>
<li><a href="/blog">Blog</a></li>
<li><a href="/stores">Stores</a></li>
<li><a href="/support">Support</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
</header>
<main><h1>Welcome</h1></main>
</body>
</html>Open it in your browser, then open developer tools and switch on device emulation, which is usually called the device toolbar or responsive design mode. Choose a width of 360 pixels. The navigation runs past the right edge of the screen.
Next, run this audit in the developer console. It reports whether the page overflows horizontally and lists every link smaller than 44 by 44 CSS pixels.
const root = document.documentElement;
const overflowsHorizontally = root.scrollWidth > root.clientWidth;
const smallLinks = [...document.querySelectorAll('nav a')]
.map((link) => ({ text: link.textContent.trim(), box: link.getBoundingClientRect() }))
.filter(({ box }) => box.width > 0 && (box.width < 44 || box.height < 44));
console.log('Horizontal overflow:', overflowsHorizontally);
console.table(
smallLinks.map(({ text, box }) => ({
link: text,
width: Math.round(box.width),
height: Math.round(box.height),
}))
);The box.width > 0 check skips the hidden dropdown links, which have no size while display: none is in effect. On the demo page you should see horizontal overflow reported as true, and every visible link listed as under 44 pixels tall, because the padding gives each only about 4 pixels above and below its text. In an emulated touch mode, tap "Products": depending on the browser, the dropdown either appears and sticks or needs a second tap.
The first two problems come from the layout, and the third from the interaction model. Neither can be fixed by shrinking the page. They need a different structure.
Common errors when adapting navigation
| Mistake | Why it fails | Better approach |
|---|---|---|
| Shrinking font and padding until the row fits | Targets fall below usable size and text becomes hard to read | Change the pattern, not the scale |
| Keeping hover dropdowns and "also" adding a touch handler | Hover emulation and click handlers fire in confusing orders | Make submenus open on click or tap and key press |
| Hiding all links behind one icon on every page | Frequent destinations become two taps away | Keep the few most used destinations visible |
| Testing only by resizing a desktop window | A resized window still has a mouse, hover, and no safe areas | Also use device emulation and a real phone |
| Building the menu from `div` elements and click handlers | Keyboard and screen reader users cannot operate it | Start from `nav`, lists, links, and `button` |
From constraints to patterns
Each constraint pushes toward a different answer, and each answer is one of the patterns in this tutorial.
In short:
- The hamburger menu answers width by collapsing every link behind one button.
- The bottom tab bar answers reach and short sessions by keeping a handful of top destinations always visible near the thumb.
- The priority menu answers variable width by showing as many links as fit and moving the rest into a "More" control.
All three share the same requirements from the constraints above: real links in semantic markup, targets large enough to tap, and no dependence on hover. The next chapters set up the foundations they all use, starting with the viewport meta tag and media queries.
Exercises
Exercise
A site's header holds a logo and seven links in a row, with a dropdown that opens on :hover. On a 360-pixel-wide phone, name the three separate constraints this design runs into and one symptom of each.
Show answer
Width: the seven links cannot fit in a row, so the header wraps, overflows past the edge, or forces tiny text. Touch precision: links with small padding give targets under 44 pixels, so users mis-tap neighbouring links. No hover: the dropdown that opens only on :hover may stick open, need a second tap, or never appear, and keyboard users cannot open it either. Thumb reach is a fourth constraint, since the controls are at the top of the screen.
Exercise
Run the audit script on your own site's navigation at a width of 360 pixels in device emulation. Record whether it overflows horizontally, how many links are smaller than 44 by 44 CSS pixels, and which of the four constraints in this chapter your navigation fails first.
Show answer
Answers vary by site. A complete answer states a true or false value for overflow, a count from the console.table output, and one named constraint with evidence, for example "7 of 9 links are under 44 pixels tall, so touch precision fails first". If the table is empty and there is no overflow, check that you ran the script with the page at 360 pixels wide and that your links sit inside a nav element.