Sub topic 1
Why Desktop Navigation Fails on Phones
Prerequisites
Assume you know basic HTML structure, semantic elements, CSS flexbox and media queries, and JavaScript event handling.
Why Desktop Navigation Fails on Phones
Desktop navigation often places every link in one horizontal row. Phones provide less width, use touch instead of a precise pointer, and are commonly held in one hand. A row that works at 1440 pixels may wrap, overflow, or make links too small at 320 pixels.
Mobile navigation should account for:
- Available width and changing orientation.
- Touch targets large enough to tap without precision.
- Thumb reach, especially near the bottom or sides of the screen.
- The importance and frequency of each destination.
Responsive Foundations: The Viewport Tag and Media Queries
The viewport meta tag tells mobile browsers to use the device width instead of rendering a shrunken desktop page. Media queries then apply layout rules at selected widths.
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.site-nav ul {
display: flex;
gap: 1rem;
}
@media (max-width: 47.99em) {
.site-nav ul {
display: none;
}
}
</style>Choose breakpoints based on where the navigation stops fitting, not on specific device names. The next chapter will replace the hidden mobile list with usable patterns.
Start with Semantic `nav` Markup
Use a nav element for a major group of navigation links. Give it an accessible name when the page has more than one navigation region. Keep links as links. A button will later control visibility, but it should not replace the destinations.
<header>
<a href="/">Site name</a>
<nav class="site-nav" aria-label="Main">
<ul>
<li><a href="/products">Products</a></li>
<li><a href="/pricing">Pricing</a></li>
<li><a href="/docs">Docs</a></li>
</ul>
</nav>
</header>Touch Targets and Thumb Reach
A touch target is the interactive area a person taps. Make links and buttons at least 48 CSS pixels high when possible, with spacing that prevents accidental taps. Put frequent actions where the thumb can reach them easily. A fixed bottom tab bar suits a small set of frequent destinations; a menu button suits a larger set of less frequent destinations.
Exercise
Why should a mobile breakpoint be based on navigation fit rather than a named phone model?
Show answer
Different devices have different widths, orientations, text settings, and browser behavior. Fit-based rules respond to the layout’s actual constraint.