Section 4.11

Interactive elements

3 entries from this section of the HTML Living Standard, in the order the standard presents them.

Read this section of the standard ↗

All 3 elements together

One small page that uses every element of this section. Turn on Show tags and point at any part of the page: a label tells you which element draws it. Click to jump to that element's details below.

Interactive elements Written for this site

Every element of this section is in the page above. Point at one to find it, click it to read its details.

<div class="faq">
  <h1>Frequently asked questions</h1>
  <p class="lead">Click a question: it opens without any JavaScript. Opening one closes the others, because they share the same name.</p>

  <details name="faq" open>
    <summary>Do I need to install anything?</summary>
    <p>No. A text editor and a browser are enough to write your first page.</p>
  </details>
  <details name="faq">
    <summary>How long does it take to learn HTML?</summary>
    <p>A few days for the basics, then you keep learning by building pages.</p>
  </details>
  <details name="faq">
    <summary>Is HTML a programming language?</summary>
    <p>It is a markup language: it describes what each part of the page is.</p>
  </details>

  <button type="button" class="open" command="show-modal" commandfor="contact">Still a question? Contact us</button>

  <dialog id="contact">
    <h2>Contact us</h2>
    <p>This is a dialog box. The rest of the page is blocked until you close it.</p>
    <button type="button" command="close" commandfor="contact">Close</button>
  </dialog>
</div>

Each element in detail

<details>

Baseline: widely availablesince July 2022

WHATWG Disclosure control for hiding details

MDN The <details> HTML element creates a disclosure widget in which information is visible only when the widget is toggled into an open state. A summary or label must be provided using the <summary> element.

Live preview Example from MDN
<details>
  <summary>Details</summary>
  Something small enough to escape casual notice.
</details>

Content model

Categories
flow; interactive; palpable
Parents
flow
Children
summary*; flow
Interface
HTMLDetailsElement

Browser support

First browser version supporting <details>
Chrome 12
Edge 79
Firefox 49
Safari 6
Chrome Android 18
Safari iOS 6

First version with support, from MDN browser-compat-data.

Attributes

name
Name of group of mutually-exclusive details elements Value: Text*
open
Whether the details are visible Value: Boolean attribute

Also accepts the global attributes.

<summary>

Baseline: widely availablesince July 2022

WHATWG Caption for details

MDN The <summary> HTML element specifies a summary, caption, or legend for a <details> element's disclosure box. Clicking the <summary> element toggles the state of the parent <details> element open and closed.

Live preview Example from MDN
<details>
  <summary>
    I have keys but no doors. I have space but no room. You can enter but can't
    leave. What am I?
  </summary>
  A keyboard.
</details>

Content model

Categories
none
Parents
details
Children
phrasing; heading content
Interface
HTMLElement

Browser support

First browser version supporting <summary>
Chrome 12
Edge 79
Firefox 49
Safari 6
Chrome Android 18
Safari iOS 6

First version with support, from MDN browser-compat-data.

Attributes

No element-specific attribute.

Also accepts the global attributes.

<dialog>

Baseline: widely availablesince September 2024

WHATWG Dialog box or window

MDN The <dialog> HTML element represents a modal or non-modal dialog box or other interactive component, such as a dismissible alert, inspector, or subwindow.

Live preview Example from MDN
<button command="show-modal" commandfor="my-dialog">Open dialog</button>

<dialog id="my-dialog">
  <p>This dialog was opened using an invoker command.</p>
  <button commandfor="my-dialog" command="close">Close</button>
</dialog>

Content model

Categories
flow
Parents
flow
Children
flow
Interface
HTMLDialogElement

Browser support

First browser version supporting <dialog>
Chrome 37
Edge 79
Firefox 98
Safari 15.4
Chrome Android 37
Safari iOS 15.4

First version with support, from MDN browser-compat-data.

Attributes

open
Whether the dialog box is showing Value: Boolean attribute

Also accepts the global attributes.