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

  1. The semantic structure of the FAQ is conveyed with native dl, dt and dd elements. So that the list structure is communicated to assistive technologies, instead of applying a button role to the dt element, a button element is contained within the dd element. Similarly, the container for the answer content that is shown and hidden is inside of the dd element so the dl structure is complete even when the answers are all hidden.
  2. The visual indication of expanded and collapsed states is synchronized with the value of aria-expanded using a CSS atribute selector and :before pseudo element that generates an image with the content property.
  3. The interactivity of the question is visually indicated on focus and hover:
    • The CSS :focus pseudo class is used to change the background and border colors.
    • The CSS :hover pseudo class is used to change the background color and underline the text.

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
    • Indicates that the container controlled by the disclosure button is hidden.
    • CSS attribute selectors (e.g. [aria-expanded="false"]) are used to synchronize the visual states with the value of the aria-expanded attribute.
    • The visual indicator of the show/hide state is created using CSS :before pseudo element and content property so the image is reliably rendered in high contrast mode of operating systems and browsers.
    aria-expanded="true" button
    • Indicates that the container controlled by the disclosure button is visible.
    • CSS attribute selectors (e.g. [aria-expanded="true"]) are used to synchronize the visual states with the value of the aria-expanded attribute.
    • The visual indicator of the show/hide state is created using CSS :before pseudo element and content property so the image is reliably rendered in high contrast mode of operating systems and browsers.

    Javascript and CSS Source Code

    HTML Source Code