๐Ÿงญ Chapter 44: Accessible Navigation & Structure

Accessible Tooltips

Crafting keyboard-operable, screen-reader-linked microcopy with `role="tooltip"`, `aria-describedby`, and WCAG 1.4.13 Content on Hover or Focus compliance.

LEARNING OBJECTIVES โŒต
  • Understand why native HTML title attributes fail modern accessibility benchmarks.
  • Implement the WAI-ARIA Tooltip Pattern using role="tooltip" and aria-describedby.
  • Comply with all three mandates of WCAG 2.2 Success Criterion 1.4.13 (Dismissible, Hoverable, Persistent).
  • Build responsive CSS and JavaScript triggers that synchronize mouse hover, keyboard focus, and Escape key dismissal.
๐ŸŽฌ INTERACTIVE VISUAL PIPELINE Core Architecture Simulation
๐ŸŒ
1. Input
Directives & Tags
โš™๏ธ
2. Parse
Tokenizer & AST
๐ŸŒณ
3. Layout
Box Model & Flow
๐ŸŽจ
4. Render
GPU Paint & Composite
PHASE 1: INPUT & DIRECTIVES
Browser receives declarative markup stream, parsing tag tokens and initializing component state.

๐Ÿ“– The Mental Model & Story (Intuitive Foundation)

Imagine walking through an art museum inspecting ancient artifacts. Beside a display case is an obscure bronze dial. As you lean in to look closely, a museum docent quietly whispers in your ear: "That dial was used by Greek sailors to calculate lunar eclipses."

If you lean back, the docent stops talking. If you find the explanation distracting, you can politely hold up your hand, and the docent steps back immediately.

Visual Pointer User:
[Hover over Icon Button] โ”€โ”€โ”€> [Tooltip bubble pops up] โ”€โ”€โ”€> [Hover over bubble to read]

Keyboard User:
[Tab onto Icon Button] โ”€โ”€โ”€> [Tooltip appears & is spoken] โ”€โ”€โ”€> [Press Escape to dismiss]

In web interfaces, a Tooltip is that quiet docent. It provides non-essential supplementary context to an interactive control without cluttering the main visual layout.

However, when tooltips are coded poorly, they become nightmares:

  • They disappear when you try to hover over them to zoom in.
  • They pop up on screen and permanently obscure the text underneath.
  • They never appear for keyboard users.
  • They are completely invisible to screen readers because they rely on fragile CSS :hover hacks.

Technical Deep Dive & Specifications

Why the Native title Attribute is Obsolete

For decades, developers relied on <button title="Print Document">. However, the native title attribute suffers from fatal accessibility defects:

Problem Native title Attribute Accessible ARIA Tooltip
Keyboard Accessibility โŒ Never triggers on keyboard focus in most browsers โœ… Triggers immediately on :focus and :focus-visible
Touchscreen Devices โŒ No touch trigger support on mobile iOS/Android โœ… Can be toggled on long-press or tap
WCAG 1.4.13 Compliance โŒ Cannot be dismissed via Escape, not hoverable โœ… Fully dismissible, hoverable, and persistent
Visual Styling โŒ Hardcoded by OS window manager, microscopic font โœ… Fully styleable with CSS Custom Properties and animations
Screen Magnifiers โŒ Disappears if user moves magnifier cursor over text โœ… User can move mouse over tooltip content safely

The WAI-ARIA Tooltip Architecture

+-------------------------------------------------------------------------------+
|  TRIGGER ELEMENT:                                                             |
|  <button aria-describedby="tip-save" aria-label="Save File">                  |
|    <svg aria-hidden="true">...</svg>                                          |
|  </button>                                                                    |
+-------------------------------------------------------------------------------+
                               โ”‚
                       aria-describedby
                               โ”‚
                               โ–ผ
+-------------------------------------------------------------------------------+
|  TOOLTIP CONTAINER:                                                           |
|  <div id="tip-save" role="tooltip" class="tooltip-bubble">                    |
|    Saves your changes to cloud storage (Ctrl+S)                               |
|  </div>                                                                       |
+-------------------------------------------------------------------------------+
  1. aria-describedby Relationship: Connects the interactive trigger to the tooltip <div>. Screen readers announce:

    "Save File, button. Saves your changes to cloud storage (Ctrl+S)."

  2. role="tooltip": Identifies the element as a temporary supplementary bubble in the Accessibility Tree.
  3. No Interactive Children: A tooltip must never contain links, inputs, or buttons. If content requires user interaction, it is a Popover or Dialog, not a tooltip.

WCAG 2.2 Success Criterion 1.4.13: Content on Hover or Focus

To meet Level AA compliance, every tooltip must satisfy the D.H.P. Rule:

+โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€+
|                     WCAG 1.4.13 THREE CORE CRITERIA                         |
+โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€+
|  1. DISMISSIBLE   | Pressing [Escape] or triggering an action closes the    |
|                   | tooltip without moving pointer hover or keyboard focus. |
|โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€|โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€|
|  2. HOVERABLE     | Pointer can move from the trigger onto the tooltip      |
|                   | container itself without the tooltip closing.           |
|โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€|โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€|
|  3. PERSISTENT    | Tooltip remains visible until hover/focus is removed or  |
|                   | explicitly dismissed by the user.                       |
+โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€+

๐Ÿ’ป Interactive Code Playground

Starter Code

Line-by-Line Code Breakdown

  • Line 87 (aria-describedby="tooltip-bookmark"): Associates the button with the tooltip message in the browser's accessibility graph.
  • Line 96 (role="tooltip"): Declares the semantic role of the floating text bubble.
  • Line 66โ€“71 (.tooltip-wrapper:hover .tooltip-box, .tooltip-box.is-visible): Enables the Hoverable rule. If a low-vision user moves their mouse from the button into the tooltip box to read it under screen magnification, pointer-events: auto ensures the tooltip does not collapse.
  • Line 106โ€“110 (if (e.key === 'Escape')): Satisfies the Dismissible rule, allowing users to close the overlay with Escape without losing focus.

Expected Browser Render Output

  • Sighted Display: Hovering over the bookmark icon displays a crisp slate tooltip saying "Save this article to your reading list".
  • Screen Reader Vocalization:

    "Bookmark, button. Save this article to your reading list."


SYS: ACTIVE
HULL: 98%
CORE: STABLE
NET: ONLINE
HTML STARSHIP CODE TERMINAL playground.html
LIVE RENDER & DIAGNOSTICS CORE TEMP: 45ยฐC
INSPECTING DOM: VALID
TAGS: SCANNING...

๐Ÿ‹๏ธ Hands-On Exercise

๐ŸŽฏ The Challenge: Accessible Markdown Toolbar Tooltips

Build an accessible formatting toolbar containing three icon buttons: Bold, Italic, and Insert Code.

Instructions:

  1. Create three <button class="toolbar-btn"> elements.
  2. Mark each button with an aria-label (e.g. aria-label="Bold text") and an aria-describedby pointing to its keyboard shortcut tooltip (e.g., Ctrl+B).
  3. Markup the corresponding <div role="tooltip"> containers.
  4. Support keyboard focus, mouse hover, and Escape key dismissal across all three tooltips.

๐Ÿ Starter Code Sandbox

SYS: ACTIVE
HULL: 98%
CORE: STABLE
NET: ONLINE
STARTER CODE SANDBOX exercise.html
LIVE RENDER & DIAGNOSTICS CORE TEMP: 45ยฐC
INSPECTING DOM: VALID
TAGS: SCANNING...

โš ๏ธ Common Pitfalls

  1. Placing Interactive Content inside a Tooltip: Putting links, checkboxes, or buttons inside role="tooltip" violates WAI-ARIA authoring practices. Use a Popover or Dialog widget instead.
  2. Using aria-label instead of aria-describedby on the Trigger: Overwriting aria-label replaces the button's accessible name rather than appending supplementary guidance.
  3. Disappearing on Hover Over Bubble: If the tooltip vanishes the moment the pointer moves off the trigger and onto the tooltip text, you fail WCAG 1.4.13 (Hoverable).
  4. No Keyboard Dismissal: Failing to dismiss active tooltips on Escape traps screen magnifier users beneath the floating box.

๐Ÿ’ก Pro Tips

  1. Explore the Baseline Popover API: Modern browsers support popover="hint" and interesttarget for declarative native tooltips.
  2. Positioning Engines (Floating UI): For dynamic viewport boundaries (preventing tooltips from clipping off the top or right edges of the screen), use @floating-ui/dom.
  3. Touch Device Strategy: Tooltips generally do not apply to touch screens. Ensure essential information is displayed as permanent text or opened in a modal on tap.

๐Ÿ“Œ Key Takeaways

  • Native HTML title attributes fail multiple WCAG standards and should be avoided for primary UI microcopy.
  • Always link tooltips using aria-describedby="[tooltip-id]" paired with role="tooltip".
  • WCAG 1.4.13 requires tooltips to be Dismissible (Escape), Hoverable (pointer can hover over bubble), and Persistent (stays until dismissed).
  • Tooltips must only contain static, non-interactive text strings.
  • --
โญ LEARN: HTML ๐ŸŒŸ โš”๏ธ QUIZ BATTLE ARENA // ACTIVE
3x
STREAK!
BONUS ACTIVE
COMBO
? Question 1 / 3

Why does WCAG Success Criterion 1.4.13 require tooltips to be "Hoverable" (pointer can move over the tooltip content itself)?

Question 1 / 3 Topic: HTML Fundamentals
00:45 REMAINING
XP REWARD
+250 XP
3x
STREAK!
BONUS ACTIVE
COMBO
? Question 2 / 3

What type of content is explicitly FORBIDDEN inside an element with role="tooltip"?

Question 2 / 3 Topic: HTML Fundamentals
00:45 REMAINING
XP REWARD
+250 XP
3x
STREAK!
BONUS ACTIVE
COMBO
? Question 3 / 3

Which ARIA attribute connects a trigger button to a supplementary tooltip without replacing the button's primary name?

Question 3 / 3 Topic: HTML Fundamentals
00:45 REMAINING
XP REWARD
+250 XP