Expandable Content <details>

HTML Living Standard

Use details to let readers expand supporting information when they need it, such as the answer to a frequently asked question.

On this page

How <details> and <summary> work

Place summary first inside details. It is the label and the control users activate. The browser shows the remaining content when details is open and hides it when closed. Add the boolean open attribute to start expanded. Remove the attribute completely to start closed because open="false" still counts as present.

How to try it In index.html, replace the content between <body> and </body> with this example. Save the file and reload it in the browser.

<details>
  <summary>Can I change my order?</summary>
  <p>You can change it before payment.</p>
</details>

What to expect The question starts visible. Click it, or focus it and press Enter or Space, to show and hide the answer. The browser does this without any JavaScript.

Official references