DOM Properties

HTMLDetailsElement.open

Read/write. Reflects whether the native disclosure is expanded. Assigning true adds the open attribute and reveals details; false removes it. Do not write open="false" in HTML to close it, because open is Boolean. Example result: true.

Formal Syntax & Structure

html syntaxhtml
element.open

Return Value

boolean

Property value. Read/write.

Working Example

Example Snippethtml
<details id="demo">  <summary>More</summary>  Details</details><p>  Result:  <output id="result"></output></p><script>  const e = document.getElementById('demo');  const result = value => { document.getElementById("result").textContent = String(value); };  e.open=true; result(e.hasAttribute('open'));</script>
HTML Reference