Skip to content

HTML Details and Summary: Test an Expandable FAQ With the Keyboard

Use Tab, Enter and Space to check a native FAQ. Compare its expanded state and answer text with a click-only control in Chrome’s accessibility tree.

A finger on a keyboard space bar beside a lifted paper flap revealing purple
Jack Lee
2 Min Read
Share
On This Page

A trial-class FAQ opens when you click its question. A parent moving through the booking page with a keyboard should be able to find the question, open the answer and close it again. Test that sequence before adding extra controls.

Start with the native disclosure

<details>
  <summary>Can I book a trial?</summary>
  <p>Choose a class time.</p>
</details>

The summary names the disclosure. Keep the question meaningful when read on its own. A visible focus indicator shows which question will react to the next key.

Follow the state through three keystrokes

We tested a local page in desktop Chrome and read its accessibility tree after each key. The answer was a single sentence, so we could check whether it was exposed.

ActionExpanded stateAnswer in accessibility tree
Tab to the questionFalseAbsent
Press EnterTruePresent
Press SpaceFalseAbsent

Check a custom question with the same keys

Our comparison used a focusable div with a click handler. Tab reached it, but Enter and Space left the answer absent from Chrome’s accessibility tree. A mouse click exposed the text, while the control still had no expanded state. A custom disclosure needs button semantics, keyboard activation and a state that tracks the visible answer.

Tab to the first question without touching the mouse. Press Enter, read the answer, press Space, then Tab to the next control. Keep the focus indicator in view throughout. If an icon has no useful spoken label, inspect its accessible name. If the answer contains a form, check its field labels.

Frequently asked questions

How do I use the summary element?

Place it first inside details and write the question readers use to recognize the answer.

Is it enough that Tab reaches the question?

Tab establishes focus. Activate the question and confirm the answer and expanded state both change.

Does a desktop Chrome check cover every screen reader?

It covers the tested browser and its accessibility tree. Repeat the interaction with the browsers and assistive technology your readers use.

Share This Article