The HTMLDetailsElement interface provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating <details> elements.
Inherits properties from its parent, HTMLElement.
HTMLDetailsElement.nameA string reflecting the name HTML attribute, which allows you to create a group of mutually-exclusive <details> elements. Opening one of the named <details> elements of this group causes other elements of the group to close.
HTMLDetailsElement.openA boolean value reflecting the open HTML attribute, indicating whether or not the element's contents (not counting the <summary>) is to be shown to the user.
No specific method; inherits methods from its parent, HTMLElement.
Inherits events from its parent interface, HTMLElement.
This example uses the HTMLElement toggle event to add and remove chapters from a log aside as they are opened and closed.
<section id="summaries">
<p>Chapter summaries:</p>
<details id="ch1">
<summary>Chapter I</summary>
Philosophy reproves Boethius for the foolishness of his complaints against
Fortune. Her very nature is caprice.
</details>
<details id="ch2">
<summary>Chapter II</summary>
Philosophy in Fortune's name replies to Boethius' reproaches, and proves
that the gifts of Fortune are hers to give and to take away.
</details>
<details id="ch3">
<summary>Chapter III</summary>
Boethius falls back upon his present sense of misery. Philosophy reminds him
of the brilliancy of his former fortunes.
</details>
</section>
<aside id="log">
<p>Open chapters:</p>
<div data-id="ch1" hidden>I</div>
<div data-id="ch2" hidden>II</div>
<div data-id="ch3" hidden>III</div>
</aside>
body {
display: flex;
}
#log {
flex-shrink: 0;
padding-left: 3em;
}
#summaries {
flex-grow: 1;
}
function logItem(e) {
console.log(e);
const item = document.querySelector(`[data-id=${e.target.id}]`);
item.toggleAttribute("hidden");
}
const chapters = document.querySelectorAll("details");
chapters.forEach((chapter) => {
chapter.addEventListener("toggle", logItem);
});
| Specification |
|---|
| HTML> # htmldetailselement> |
| HTML> # event-toggle> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
HTMLDetailsElement |
10 | 79 | 49 | 15 | 6 | 18 | 49 | 14 | 6 | 1.0 | 4.4 | 6 |
name |
120 | 120 | 130 | 106 | 17.2 | 120 | 130 | 80 | 17.2 | 25.0 | 120 | 17.2 |
open |
10 | 79 | 49 | 15 | 6 | 18 | 49 | 14 | 6 | 1.0 | 4.4 | 6 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
HTMLDetailsElement |
36 | 79 | 49 | 23 | 10.1 | 36 | 49 | 24 | 10.3 | 3.0 | 37 | 10.3 |
<details>
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLDetailsElement