SIA-R116<summary> element has non-empty accessible name

Accessibility requirements

This rule is not required for conformance to any accessibility requirements.

Description

This rule checks that each <summary> element has a non-empty accessible name.

Applicability

This rule applies to every <summary> element in the HTML namespace for which all the following are true:

Expectations

  1. The element has an accessible name that is not empty, nor just the name of the ::marker pseudo-element.

Assumptions

The rule assumes that all <summary> elements are user interface components as defined by WCAG 2.

Accessibility Support

There is a difference in how user agents expose ::marker pseudo-element (the triangle indicating the control's expand state). As a result, some user agents include it in the accessible name of the <summary> element but other don't.

Some user agents expose the <summary> element with a button role, which deviates from its implicit ARIA semantics described in ARIA in HTML. Because some browsers do not give <summary> elements a button role, the presence of an accessible name must be treated separately for button role and <summary> elements.

Background

This rule is only applicable to <summary> elements that the browser will use as controls for a <details> element.

This rule is not applicable to <summary> elements with an explicit semantic role. Most of the time these likely do require an accessible name; this is covered by other rules.

Examples

Passed

This <summary> element has an accessible name because of its text content.

<details>
    <summary>Opening times</summary>
    <p>This is a website. We are available 24/7.</p>
</details>

This <summary> element has an accessible name because of its aria-label attribute.

<details>
    <summary aria-label="Opening times"></summary>
    <p>This is a website. We are available 24/7.</p>
</details>

Failed

This <summary> element has no accessible name, or an accessible name with just the ::marker pseudo-element, because it has no content nor attribute that can provide it.

<details>
    <summary></summary>
    <p>This is a website. We are available 24/7.</p>
</details>

This <summary> element has an explicit role of none. However, it is focusable (by default) which causes Presentational Roles Conflict Resolution. It fails because it has an empty accessible name.

<details>
    <summary role="none"></summary>
    <p>This is a website. We are available 24/7.</p>
</details>

Inapplicable

This <summary> element is not a child of a <details> element and so is not the summary button for its parent <details> element

<summary></summary>

This <summary> element is not a direct child of a <details> element and so is not the summary button for its parent <details> element

<details>
    <div>
        <summary></summary>
    </div>
    <p>This is a website. We are available 24/7.</p>
</details>

This <summary> element has an explicit semantic role of button. These are tested by another rule. Note that while this example does not fail WCAG, under ARIA in HTML it is not allowed to override the role of a summary for its parent details.

<details>
    <summary role="button">Opening hours</summary>
    <p>This is a website. We are available 24/7.</p>
</details>

Acknowledgments

This document includes material copied from or derived from https://www.w3.org/WAI/standards-guidelines/act/rules/2t702h/. Copyright © 2024 W3C® (MIT, ERCIM, Keio, Beihang).