Skip to content

A closed <details> reads its hidden content, and its summary without button/collapsed #254

Closed

Description

@Elizabeth1979

Markup

<main><details><summary>Plan details</summary><p>Hidden part</p></details></main>

Virtual Screen Reader says (0.32.1 and 0.33.0):

main, group, Plan details, paragraph, Hidden part, end of paragraph, end of group, end of main

Expected: the summary read as a collapsed button (for example button, Plan details, not expanded), and nothing from the content while the details is closed.

  • HTML-AAM maps the details' summary to a button whose expanded state follows the details' open attribute.
  • The HTML standard does not render a closed details' content beyond its summary, and Chromium's accessibility tree marks that content as not rendered, so screen readers do not read it. Reading it tells a user about content they cannot reach.

Environment: the browser bundle (@guidepup/virtual-screen-reader/browser.js) in Chromium 151 via Playwright 1.63, started with virtual.start({ container: document.body }), stepped with virtual.next().

Activity

  1. cmorten commented on Oct 17, 2026

    @cmorten
    Contributor

    R.E. "the summary read as a collapsed button"

    Some quote/refs from specs:

    [wai-aria-1.2] - No corresponding role
    Computed Role - If the element is the first child of its type within a parent details element: html-summary. Otherwise, if it is not the first child of its type of a parent details element, or it is not a child of a details element: generic role

    The specific accessibility APIs (UIA, AX, etc.) do typically expose as some form of expand/collapse like button.

    REF: https://www.w3.org/TR/html-aam-1.0/#el-summary

    No role if the summary element is a summary for its parent details element.

    Note
    The exposed role of a summary element can vary depending on the user agent and assistive technology.

    REF: https://www.w3.org/TR/html-aria/#docconformance

    From memory/experience the expected role of summary element is somewhat contested, but my read is that officially it doesn't have an implicit role in the sense that this library typically exposes, and that user agents and assistive technologies have (because to many this feels like a gap given it is an interactive button like thing) made up their own choices on how to expose it (prompting the note in the ARIA in HTML spec).

    Generally I've looked to be spec aligned and not implementation aligned (citation needed, probably not done this consistently!) which hints at us adopting the spec's No corresponding role definition for <summary> elements.

    If you have spec or WPT links that speak to the contrary then please share and can reconsider!


    R.E. "HTML standard does not render a closed details' content beyond its summary" need to have a deeper look, nothing stands out that can see from the aria related specs, but if HTML specs consider it not rendered then agree we should treat it like it's either not there!

  2. cmorten commented on Oct 17, 2026

    @cmorten
    Contributor
    1. The second child element is a slot that is expected to take the details element's remaining descendants, if any. This element has no contents.

    This element is expected to match the '::details-content' pseudo-element.

    This element is expected to have its style attribute set to "display: block; content-visibility: hidden;" when the details element does not have an open attribute. When it does have the open attribute, the style attribute is expected to be set to "display: block;".

    Because the slots are hidden inside a shadow tree, this style attribute is not directly visible to author code. Its impacts, however, are visible. Notably, the choice of content-visibility: hidden instead of, e.g., display: none, impacts the results of various APIs that query layout information.

    REF: https://html.spec.whatwg.org/multipage/rendering.html?utm_source=chatgpt.com#the-details-and-summary-elements

    So the HTML described behaviour of a closed details-summary is to apply content-visibility: hidden. This then points to:

    hidden

    The element skips its contents.

    The skipped contents must not be accessible to user-agent features, such as find-in-page, tab-order navigation, etc., nor be selectable or focusable.

    Note: This is similar to giving the contents display: none.

    REF: https://www.w3.org/TR/css-contain-2/?utm_source=chatgpt.com#content-visibility

    The "must not be accessible to user-agent features, such as find-in-page, tab-order navigation, etc., nor be selectable or focusable" and comparison to display: none settles it IMO, so I agree, we should omit the children of a collapsed <details> element from the constructed tree.

  3. added theissue type on Oct 17, 2026
  4. cmorten commented on Oct 23, 2026

    @cmorten
    Contributor

    With #266 merged I believe this is complete.

    Message if disagree (with citations!) r.e. the button role and we can discuss further!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions