<details> is a disclosure widget that works without script. Its first <summary> child is the label and toggle; everything else is the content, shown only while the boolean open attribute is present. Without a <summary>, the browser supplies its own label (the standard's example is "Details").
- The summary is focusable, and a click, Enter or Space on it toggles
open. Script can do the same withdetails.open = true. - Every change queues a
toggleevent witholdStateandnewState. It fires on the<details>and doesn't bubble, so delegate with a capture listener. Changes made in one task are coalesced into one event. - The marker comes from CSS: the summary is
display: list-itemwithlist-style-type: disclosure-closedordisclosure-open, sosummary { list-style: none }removes it and::markerstyles it. The content sits in a slot hidden withcontent-visibility: hidden, which::details-contentcan style. - Navigating to a fragment inside a closed
<details>opens it, and so does find-in-page in browsers that support it (Chrome 97, Firefox 148; Safari partly).
Exclusive accordions. Give several <details> the same name and they form a details name group: opening one closes the others in the group. The browser enforces it everywhere: on user toggles, on open = true from script, and while parsing, where a second open member is closed. Closing the open one is allowed, so the group can be fully collapsed. Members only need the same name in the same tree; they don't have to be siblings.
Use <details> for show-more content, FAQs and filters. The standard rules it out for tabs and menus, which are different widgets.