Example Disclosure (Show/Hide) for Answers to Frequently Asked Questions
The following example demonstrates using the disclosure design pattern to create a set of frequently asked questions where the answers may be independently shown or hidden.
Similar examples include:
Example
-
Park at the nearest available parking meter without paying the meter and call 999-999-9999 to report the problem. We will note and approve your alternate location and will investigate the cause of the shortage in your assigned facility.
-
You should come to the Parking office and report the loss. There is a fee to replace your lost permit. However, if your permit was stolen, a copy of a police report needs to be submitted along with a stolen parking permit form for a fee replacement exemption.
-
All facilities are restricted from 2:00 am - 6:00 am on all days. No exceptions are made for any holiday or recess except those officially listed as a
Holidays
in the calendar. Please note: 24-hour rental spaces, 24-hour rental lots, and disabled parking is enforced at all times. -
Some parking facility restrictions differ from others. Be sure to take note of the signs at each lot entrance.
Accessibility Features
-
The semantic structure of the FAQ is conveyed with native
dl,dtandddelements. So that the list structure is communicated to assistive technologies, instead of applying a button role to thedtelement, abuttonelement is contained within theddelement. Similarly, the container for the answer content that is shown and hidden is inside of theddelement so thedlstructure is complete even when the answers are all hidden. - The visual indication of expanded and collapsed states is synchronized with the value of
aria-expandedusing a CSS atribute selector and:beforepseudo element that generates an image with thecontentproperty. - The interactivity of the question is visually indicated on focus and hover:
- The CSS
:focuspseudo class is used to change the background and border colors. - The CSS
:hoverpseudo class is used to change the background color and underline the text.
- The CSS
Keyboard Support
| Key | Function |
|---|---|
| Tab | Moves keyboard focus to the disclosure button. |
|
Space or Enter |
Activates the disclosure button, which toggles the visibility of the answer to the question. |
Role, Property, State, and Tabindex Attributes
| Role | Attribute | Element | Usage |
|---|---|---|---|
aria-controls="IDREF"
|
button
|
The disclosure button controls visibility of the container identified by the IDREF value.
|
|
aria-expanded="false"
|
button
|
|
|
aria-expanded="true"
|
button
|
|
Javascript and CSS Source Code
- CSS: disclosure-faq.css
- Javascript: disclosureButton.js
HTML Source Code