Be sure to add
aria-expanded to the control element. This attribute explicitly conveys the current state of the collapsible element tied to the control to screen readers and similar assistive technologies. If the collapsible element is closed by default, the attribute on the control element should have a value of
aria-expanded="false". If you’ve set the collapsible element to be open by default using the
show class, set
), the attribute
role="button" should be added to the element.
If your control element is targeting a single collapsible element – i.e. the
data-target attribute is pointing to an
id selector – you should add the
aria-controls attribute to the control element, containing the
id of the collapsible element. Modern screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.
The collapse plugin utilizes a few classes to handle the heavy lifting:
.collapsehides the content
.collapse.showshows the content
.collapsingis added when the transition starts, and removed when it finishes
These classes can be found in
data-toggle="collapse" and a
data-target to the element to automatically assign control of one or more collapsible elements. The
data-target attribute accepts a CSS selector to apply the collapse to. Be sure to add the class
collapse to the collapsible element. If you’d like it to default open, add the additional class
To add accordion-like group management to a collapsible area, add the data attribute
data-parent="#selector". Refer to the demo to see this in action.