Structure
Use nav, lists or clear link groups where appropriate.
Navigation CSS helps users understand where they are, where they can go and what path matters next.
.nav { display: flex; flex-wrap: wrap; gap: .5rem; }
.nav a[aria-current="page"] { color: var(--green); }
.nav a:focus-visible { outline: 3px solid var(--focus); }
Component mental model
Navigation is one of the most important components on a site. It should be predictable, scannable and usable before it becomes visually expressive.
Good navigation styling makes current location, available sections and primary actions obvious.
Responsive navigation must work with touch, keyboard and long labels. A beautiful desktop nav that collapses badly is not production ready.
Use nav, lists or clear link groups where appropriate.
Show the current page or section clearly.
Links need room to scan and tap.
Choose wrap, scroll, disclosure or drawer intentionally.
Visual model
Good CSS versus fragile CSS
.nav { display: flex; flex-wrap: wrap; gap: .5rem; }
.nav a { min-height: 44px; display: inline-flex; align-items: center; }
.nav a[aria-current="page"] { color: var(--green); }
.nav a:focus-visible { outline: 3px solid var(--focus); }
.nav a { padding: 4px; }
.nav a:hover { color: red; }
.nav .current { display: none; }
Rules of thumb
Users should not need to guess where they are.
Every nav link needs a visible focus style.
Navigation should not break when a label grows.
Small nav links are painful on mobile.
Touch and keyboard users need an accessible pattern.
Too many top-level links reduce scanning quality.
Production thinking
Navigation controls the perceived complexity of a site. If the nav feels messy, the whole product feels messy.
Use aria-current for the active page when appropriate and keep navigation reachable by keyboard.
Test navigation at narrow widths, with zoom and with translated or longer labels.
Clear internal navigation helps crawlers and users discover important sections.
Live code lab
The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these questions before moving on. If a state, long label or mobile width breaks the component, the component is not finished yet.
Senior audit upgrade
Hover dropdowns can look done, but keyboard behavior, open state, escape behavior and aria state usually require JavaScript too.
Touch and keyboard users need a way to open and close menus.
Mark the current page or section when navigation points to the active location.
Start with real links that work before adding dropdown behavior.