Skip to content

Details and summary styles don't match implementations. #8610

Closed

Description

@emilio

https://html.spec.whatwg.org/#the-details-and-summary-elements has:

summary {
  display: list-item;
  counter-increment: list-item 0;
  list-style: disclosure-closed inside;
}
details[open] > summary {
  list-style-type: disclosure-open;
}

However a quick test like this:

<!doctype html>
<details>
  <summary>Example</summary>
  <summary>Another</summary>
</details>
<details open>
  <summary>Example</summary>
  <summary>Another</summary>
</details>
<details>
  Anonymous
</details>

shows that the rules browsers actually use are different. The selectors are something like details > summary:first-of-type and details[open] > summary:first-of-type, with extra similar styles for the anonymous summary.

I think we could change browsers to follow the spec if needed, but it might be better to make the spec match reality?

Activity

  1. added
    topic: rendering
    agenda+
    on Dec 12, 2022
  2. scottaohara commented on Dec 12, 2022

    @scottaohara
  3. emilio commented on Dec 12, 2022

    @emilio
    ContributorAuthor

    That's how browsers behave, and what I'm proposing, unless I'm missing something?

  4. scottaohara commented on Dec 12, 2022

    @scottaohara
    Contributor

    nope, not missing anything. rather i was missing the fact that the styles i was seeing were due to revised default styling from normalize.css which i didn't realize was referenced form the file i was testing.

    so... i'll just excuse myself from this and go file a bug over there. sorry about that.

  5. added a commit that references this issue on Dec 13, 2022
  6. domenic commented on Jan 13, 2023

    @domenic
    Member

    On the triage call, everyone was leaning toward changing the spec to match browser behavior, but we took an action item to read up a bit more to confirm.

    Upon doing so, I think changing the spec to match browser behavior is indeed the best path here. That makes the styling consistent with the behavior. (Everything in https://html.spec.whatwg.org/#the-details-and-summary-elements except the stylesheet mentions "first summary element child", and https://html.spec.whatwg.org/#summary-for-its-parent-details also requires it to be the first element child.)

    So, a PR and test updates would be lovely from my perspective.

  7. jakearchibald commented on Jan 23, 2023

    @jakearchibald
    Contributor

    Somewhat related, I think we should have a pseudo-element selector for the default <summary> #8770

  8. added a commit that references this issue on Jan 26, 2023
    c190cc5
  9. removed
    agenda+
    on Jan 26, 2023
  10. added a commit that references this issue on Jan 27, 2023
    0f1d234
  11. added a commit that references this issue on Sep 16, 2025
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

    topic: rendering

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions