Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

open — the open state of details and dialog

The boolean open attribute controls whether details is expanded or dialog is open. Its presence matters, not its text value; open alone does not create a modal dialog.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

<details open>…</details>
<dialog open>…</dialog>
open | open="" | open="open"

open is a boolean attribute on details and dialog, not a global attribute. Valid forms are open, open="", and open="open". Writing open="false" is invalid and still leaves the attribute present; a false state requires omitting it.

On details, open reveals additional content alongside summary; without it, only the summary appears. Activating summary toggles the attribute. The DOM property open reflects its presence.

On dialog, open alone opens a non-modal dialog; modality requires showModal(). Close it with close() rather than manually removing the attribute: manual removal skips the close event and, after showModal(), can leave the document blocked.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>open attribute</title>
<details open>
  <summary>Details</summary>
  <p>Additional information.</p>
</details>
<dialog open>
  <p>Non-modal dialog.</p>
</dialog>
<pre id="result"></pre>
<script>
  const details = document.querySelector('details');
  const dialog = document.querySelector('dialog');
  const states = [`${details.open} ${dialog.open}`];
  details.open = false;
  dialog.close();
  states.push(`${details.open} ${dialog.open}`);
  document.getElementById('result').textContent = states.join('\n');
</script>
</html>

Result

true true
false false

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources