Skip to content

Chapter 3 of 8

Keyboard Interaction and Focus

Many users, including those who are blind or have motor impairments, navigate the web primarily with a keyboard, so keyboard interaction and focus management are central to accessibility. The tabindex attribute controls whether an element is focusable and how it participates in sequential Tab navigation. A tabindex value of 0 makes an element focusable and places it in the natural document Tab order, while tabindex="-1" makes an element programmatically focusable (such as via element.focus()) but removes it from sequential Tab order. Positive tabindex values are strongly discouraged because they jump the element to the front of the Tab order ahead of natural order, making the page sequence unpredictable for keyboard users and undermining WCAG 2.4.3 Focus Order.

Every interactive element must show a visible focus indicator so keyboard users can see where they are on the page, as required by WCAG success criterion 2.4.7 Focus Visible at level AA, with at least 3:1 contrast between the indicator and its adjacent background per WCAG 1.4.11. Removing the focus ring with outline: none without providing an alternative is a common accessibility anti-pattern. The CSS pseudo-class :focus-visible solves this elegantly by applying focus styles only when the focus comes from a keyboard or other non-pointer input, so mouse clicks do not display rings but keyboard tabbing does.

A frequent anti-pattern is creating a clickable `

` with no role, no tabindex, and no key handler: such an element is not focusable and has no semantics, leaving keyboard and screen-reader users unable to reach or understand it as a control. Even `
` is inferior to a real `
All chapters
  1. 1Foundations of Web Accessibility
  2. 2ARIA Fundamentals
  3. 3Keyboard Interaction and Focus
  4. 4Live Regions and Modal Dialogs
  5. 5Common Widget Patterns
  6. 6Forms, Buttons, and Controls
  7. 7Content Semantics and Structure
  8. 8Advanced Patterns and Practices

Drill it

Reading is not remembering. These come from the Accessibility Aria Patterns deck:

Q

What does the acronym "a11y" stand for in web development?

"a11y" is a numeronym for "accessibility" — 'a' + 11 letters + 'y'.

Q

What is the difference between web accessibility (a11y) and usability?

Accessibility means people with disabilities can perceive, understand, navigate, and interact with the web. Usability is the broader quality of a design being e...

Q

Which four disability categories does WCAG primarily address?

Visual, auditory, physical/motor, and cognitive/neurological disabilities.

Q

Name the three conformance levels defined by WCAG 2.1.

A (lowest), AA (mid), and AAA (highest).