coding script
Photo by Markus Spiske on Pexels.com

The Complete Guide to Accessible Navigation & Information Architecture: Landmarks, Headings, Skip Links, Mega Menus, Breadcrumbs, and Search

Executive Summary (Key Points First)

  • Treat Information Architecture (IA) as the “map for reading order and movement,” and enable shortest-path access with landmarks, headings, and skip links.
  • Build global navigation / mega menu / breadcrumbs / search / sitemap / in-page table of contents with native HTML + minimal ARIA for robustness.
  • Design for keyboard operation, visible focus, and responsive layouts; communicate via redundant cues (color + shape + text) to prevent users from getting lost.
  • For “lost pages” like 404 / maintenance / zero results, provide return paths, a friendly tone, and alternatives.
  • Includes implementation samples (HTML/CSS/JS), operational checklist, and 5-minute smoke test.

Intended Readers (concrete): UI/UX designers, frontend engineers, information architects, editors/content designers, PMs / web directors, QA / accessibility specialists
Accessibility Level: WCAG 2.1 AA compliant (recommend WCAG 2.2 items such as target size where feasible)


1. Introduction: Navigation is both a “Map” and a “Shortcut”

Web accessibility isn’t complete with just color, contrast, and labels. You also need the map and shortcuts that get people to their destination quickly—namely information architecture (IA) and navigation.
Users are diverse: screen readers, magnifiers, keyboard, voice input, and one-handed mobile use. With landmarks (header/nav/main/aside/footer) and a proper heading structure (h1–h6), everyone can reach their target via the shortest route. Add skip links so keyboard users can jump past repeated menus straight to content.
This guide provides design and implementation “patterns” for global navigation, mega menus, breadcrumbs, search, in-page TOC, and sitemaps.


2. Build the Skeleton: Landmarks + Headings + Skip Links

2.1 Landmark Basics

  • Mark major regions with header / nav / main / aside / footer.
  • When multiple nav/aside elements exist, give each an aria-label (e.g., <nav aria-label="Global">).
<a class="skip" href="#content">Skip to main content</a>

<header>…logo / search…</header>
<nav aria-label="Global">…primary nav…</nav>
<main id="content">…page-specific content…</main>
<aside aria-label="Related information">…related articles…</aside>
<footer>…footer links…</footer>
.skip { position:absolute; left:-9999px; top:auto; }
.skip:focus { left:1rem; top:1rem; background:#111; color:#fff; padding:.5rem .75rem; border-radius:.5rem; }

2.2 Keep the “Staircase” of Headings Intact

  • Use one h1 per page. Then follow the logical content structure with h2 → h3 ….
  • Choose levels by semantic hierarchy, not visual size—control visuals with CSS.

2.3 Purpose of Skip Links

  • Reduce repetitive actions for keyboard users. Ideally appears on the first Tab.
  • Place tabindex="-1" on main to ensure focus is moved correctly.
<main id="content" tabindex="-1">…</main>

3. Global Navigation: Robust with Minimal ARIA

3.1 Keep It Simple (Recommended)

  • Start with the native structure: <nav><ul><li><a>.
  • Indicate the current page with aria-current="page" and back it up with color/text.
<nav aria-label="Global">
  <ul>
    <li><a href="/" aria-current="page">Home</a></li>
    <li><a href="/products">Products</a></li>
    <li><a href="/pricing">Pricing</a></li>
    <li><a href="/docs">Docs</a></li>
  </ul>
</nav>

3.2 Dropdowns (Disclosure Pattern)

  • Use a <button> as the trigger. Reflect state with aria-expanded; associate panel via aria-controls.
  • No focus trap (don’t force cycling). Close with Esc and return focus to the trigger.
<nav aria-label="Global">
  <ul>
    <li class="has-sub">
      <button aria-expanded="false" aria-controls="p1" id="b1">Products</button>
      <div id="p1" role="region" aria-labelledby="b1" hidden>
        <ul>
          <li><a href="/products/a">A</a></li>
          <li><a href="/products/b">B</a></li>
        </ul>
      </div>
    </li>
  </ul>
</nav>

<script>
const btn = document.getElementById('b1'), panel = document.getElementById('p1');
btn.addEventListener('click', () => {
  const open = btn.getAttribute('aria-expanded') === 'true';
  btn.setAttribute('aria-expanded', String(!open));
  panel.hidden = open;
});
document.addEventListener('keydown', e => {
  if (e.key === 'Escape' && btn.getAttribute('aria-expanded') === 'true') {
    btn.click(); btn.focus();
  }
});
</script>

Note: Avoid role="menu" for site navigation. It implies an application menu with arrow-key behavior, which confuses users on the web.


4. Mega Menus: “Compress & Deliver” Information

4.1 Design Principles

  • Use column headings with visible text (h3 equivalent); icons are supplementary.
  • Limit to ~3 columns, with 5–7 links per column. Resist “showing everything” for readability.
  • Default to click to open/close (more reliable for mobile & keyboard than hover).

4.2 Minimal Implementation Skeleton

<li class="mega">
  <button aria-expanded="false" aria-controls="mega-products" id="megaBtn">Products</button>
  <div id="mega-products" role="region" aria-labelledby="megaBtn" hidden>
    <div class="col">
      <h3>Getting Started</h3>
      <ul>
        <li><a href="/getting-started">Onboarding Guide</a></li>
        <li><a href="/tutorials">Tutorials</a></li>
      </ul>
    </div>
    <div class="col">
      <h3>Product Lines</h3>
      <ul>
        <li><a href="/products/a">A</a></li>
        <li><a href="/products/b">B</a></li>
      </ul>
    </div>
    <div class="col">
      <h3>Support</h3>
      <ul>
        <li><a href="/docs">Docs</a></li>
        <li><a href="/contact">Contact</a></li>
      </ul>
    </div>
  </div>
</li>
.mega [role="region"] { display:grid; grid-template-columns: repeat(3, minmax(10rem, 1fr)); gap:1rem; }
.mega [role="region"][hidden] { display:none; }
.mega h3 { font-size:1rem; margin:.5rem 0; }

5. Breadcrumbs: A “Short Route” to the Current Location

  • Use <ol> inside nav[aria-label="Breadcrumbs"] to indicate hierarchy/order.
  • The final item carries aria-current="page" and need not be a link.
<nav aria-label="Breadcrumbs">
  <ol>
    <li><a href="/">Home</a></li>
    <li><a href="/products">Products</a></li>
    <li aria-current="page">Details for A</li>
  </ol>
</nav>

6. Site Search: Accessible Forms & Results

6.1 Search Form

  • Provide a visible label (placeholder is not a label).
  • Use type="search" + autocomplete="on", and include a submit button.
  • Add a skip link to results on the results page (“Skip to search results”).
<form role="search" action="/search">
  <label for="q">Site Search</label>
  <input id="q" name="q" type="search" autocomplete="on">
  <button>Search</button>
</form>

6.2 Results List

  • Show the result count near a heading (e.g., “125 results found”).
  • For highlighting, don’t rely on color alone—use bold/underline too.
  • Pagination as nav[aria-label="Pagination"]; current page gets aria-current="page".
<nav aria-label="Pagination">
  <ul>
    <li><a href="?page=1">1</a></li>
    <li><a aria-current="page">2</a></li>
    <li><a href="?page=3">3</a></li>
  </ul>
</nav>

7. In-Page TOC & Section Jumps

  • For long pages, place a TOC at the top (<nav aria-label="In-page table of contents">).
  • Give each heading an ID, and on jump use smooth scroll + move focus to avoid disorientation.
<nav aria-label="In-page table of contents">
  <ol>
    <li><a href="#sec-1">1. Introduction</a></li>
    <li><a href="#sec-2">2. Design Principles</a></li>
  </ol>
</nav>

<h2 id="sec-1" tabindex="-1">Introduction</h2>
:target { scroll-margin-top: 6rem; } /* Account for fixed headers */

8. Footer & Sitemap: The Final Safety Net

  • Footer should include a summary of major categories plus contact & accessibility policy.
  • Sitemap as nav[aria-label="Sitemap"], ideally limited to ~2 levels to control visual density.

9. Mobile Navigation: Touch, Zoom, Responsive

  • Target size 44–48 px, with adequate spacing between targets.
  • Don’t use user-scalable=no; allow zoom.
  • Drawer toggles use <button aria-expanded> with labels like “Open menu / Close menu.”
  • Avoid forcing orientation.
  • Convert mega menus to accordions, opening one level at a time to reduce load.

10. Contrast, Focus, State: Make Non-Text Visible Too

  • Aim for 4.5:1 for text, 3:1 for non-text (icons, boundaries).
  • Make focus indicators hard to miss: thickness + color + outline offset.
  • Redundantly indicate current location with color + underline + aria-current.
a[aria-current="page"] { font-weight:700; text-decoration:underline; }
:focus-visible { outline:3px solid #FF9900; outline-offset:3px; }

11. Designing “Lost” Pages: 404 / Maintenance / Zero Results

  • 404:
    • Use a friendly tone to explain what happened and what to do next (search, home, popular pages).
    • For screen readers, include a clear <h1>Page not found</h1>.
  • Maintenance:
    • Provide estimated return time, impact scope, and emergency contacts in text.
  • Zero Results:
    • Offer alternatives (spelling, related terms, popular queries) and a browse by category path.

12. “Don’t Do This” Patterns & Fixes

Anti-pattern Problem Fix
role="menu" in global nav Unexpected behaviors & confusion Use native nav/ul/li/a + minimal ARIA
Placeholder = label Label disappears, ambiguous Provide a visible label; use placeholder as hint
Hover-only expansion Fails on mobile & keyboard Button-based toggle with aria-expanded
Current location via color only Unclear for color-vision diversity aria-current + underline/bold
No skip link Repetitive actions burden users Show on first Tab, move focus to main
Anchors hidden by fixed header Users land “under” the header :target { scroll-margin-top }
Zero results with no help Dead end Offer alternatives, popular links, contact

13. Template: Minimal Header & Nav (Copy-Paste Ready)

<header class="site-header">
  <a class="logo" href="/">Brand</a>
  <button id="menuBtn" aria-expanded="false" aria-controls="gNav">Menu</button>
  <nav id="gNav" aria-label="Global" hidden>
    <ul>
      <li><a href="/" aria-current="page">Home</a></li>
      <li><a href="/products">Products</a></li>
      <li><a href="/pricing">Pricing</a></li>
      <li><a href="/docs">Docs</a></li>
    </ul>
  </nav>
  <form role="search" action="/search" class="search">
    <label for="q" class="sr-only">Site Search</label>
    <input id="q" name="q" type="search" placeholder="Enter keywords">
    <button>Search</button>
  </form>
</header>

<script>
const b = document.getElementById('menuBtn'), nav = document.getElementById('gNav');
b.addEventListener('click', () => {
  const open = b.getAttribute('aria-expanded') === 'true';
  b.setAttribute('aria-expanded', String(!open));
  nav.hidden = open;
  if (!open) nav.querySelector('a')?.focus();
});
document.addEventListener('keydown', e => {
  if (e.key === 'Escape' && b.getAttribute('aria-expanded') === 'true') { b.click(); b.focus(); }
});
</script>
.sr-only{ position:absolute; left:-9999px; }
.site-header{ display:grid; grid-template-columns:auto 1fr auto; gap:1rem; align-items:center; }
#gNav ul{ display:flex; gap:1rem; list-style:none; padding:0; margin:0; }
@media (max-width:48rem){
  #gNav[hidden]{ display:none; }
  #gNav ul{ display:grid; gap:.5rem; }
}
:focus-visible{ outline:3px solid #FF9900; outline-offset:2px; }

14. IA by Page Type: Home / Listing / Detail / Form

  • Home: Limit primary paths to 3–5; show the shortest route for newcomers.
  • Listing (search/category): Order as result count → refine controls → list. Provide labeled buttons for sort/filter.
  • Detail: Combine in-page TOC, related links (prev/next / parent category), and breadcrumbs.
  • Form: Minimize global nav (or add a “Exit form” path) to reduce distractions.

15. Manual Testing (5-Minute Smoke)

  1. With Tab only, you can reach skip link → main → primary links → footer in logical order.
  2. In a screen reader, landmark and heading lists make sense.
  3. Current location is conveyed beyond color (underline/bold/aria-current).
  4. Dropdowns/mega menus toggle with a button and close with Esc, returning focus to the trigger.
  5. After in-page TOC jumps, headings aren’t hidden and reading can start immediately.
  6. On mobile, target size/spacing are sufficient; fixed headers don’t cover content.

16. Organizational Practice: Put “Map Rules” in Your Design System

  • Component Specs:
    • Name/Role/Value (NRV): document aria-expanded, aria-current, etc.
    • Key interactions: Tab / Esc / arrow behavior.
    • Contrast: minimum ratios for links, focus, icons.
  • Content Guidelines:
    • Link text should state the object/action (“Click here” is not allowed).
    • Consistent naming for breadcrumbs and titles.
  • Bake an operations checklist into PR templates; standardize CI automated checks + 5-minute manual runs.

17. Case Study: Shrinking a Mega Menu to Reduce “Decision Fatigue”

Before

  • 5 columns × 10 links = 50 links. Instant hover expansion; impossible on mobile.
  • Current location indicated by color only; unreadable via screen readers.
  • No alternatives on zero search results.

After

  • Reduced to 3 columns × 6 links = 18 links; top 3 promoted as “Recommended.”
  • Button-based open/close with aria-expanded and Esc support.
  • Unified current location: aria-current + bold + underline.
  • On zero results, show suggested keywords and category links.
  • Outcome: −23% time-to-task per session; −41% mistaps on mobile.

18. Checklist (Paste-Ready, Definition of Done)

  • [ ] Proper header/nav/main/aside/footer; multiple nav elements have aria-label
  • [ ] Logical heading structure (one h1)
  • [ ] Skip link appears on first Tab and moves focus to main
  • [ ] Global nav uses native HTML + minimal ARIA; dropdowns toggle via button
  • [ ] Current location via aria-current + visual cues (bold/underline)
  • [ ] Search form has a visible label; results count & pagination are accessible
  • [ ] After TOC jump, headings aren’t hidden (scroll-margin-top)
  • [ ] Mobile: 44–48 px targets, zoom allowed, no forced horizontal scroll
  • [ ] Zero/404/maintenance provide alternatives and a friendly tone
  • [ ] Passes the 5-minute smoke test (§15)

19. Concrete Benefits by Role

  • UI/UX Designers: Clear IA principles & nav patterns enable confident, uncluttered flows.
  • Frontend Engineers: Native + minimal ARIA templates yield regression-resistant code.
  • Information Architects / Editors: Consistent naming for titles, breadcrumbs, and link text improves findability & reuse.
  • PMs / Directors: AA acceptance criteria are explicit, easing release decisions.
  • QA / A11y Specialists: Stable test oracles for landmarks, headings, skip links, current location.
  • Users (AT, keyboard, mobile): Reach goals via the shortest route with less confusion and fatigue.

20. Wrap-Up: Shortest Path, Kinder UX, Shared Understanding

  1. Establish the map with landmarks, headings, and skip links.
  2. Keep nav robust with native HTML + minimal ARIA.
  3. Don’t rely on color alone—redundant signals prevent getting lost.
  4. Keep search, breadcrumbs, and in-page TOC as alternative routes.
  5. Design mobile-first with target size, zoom, and careful toggles.
  6. Provide rescues for lost pages (404 / zero results / maintenance) with a friendly tone.
  7. Maintain quality with repeatable tests (5-minute smoke) and a checklist.

Navigation is a quiet guide that stands with your users. May your site become a place where everyone arrives without getting lost, without extra effort, and with the same understanding.


By greeden

Leave a Reply

Your email address will not be published. Required fields are marked *

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)