Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Sep 9, 2021Updated May 27, 2022
Contribute to Docs

The <details> semantic HTML element encapsulates the <summary> element and any additional elements that are only visible when the <details> element is in an open state.

There is a small triangle which shows the state of the element. By clicking on the element or using the space bar, the state can be toggled between revealing and hiding additional information.


The <details> element can be in two states, closed and open:

  • When in the closed state, only the content in the <summary> element is visible.
  • However, when the <details> element is toggled into an open state, the <summary> and any additional content inside the <details> element are visible.

The <details> element must contain a <summary> element which will provide a label for the hidden additional details.

<summary>Summary Text Here</summary>
<!-- Extra content here -->


<!DOCTYPE html>
<head> </head>
<!-- The details element -->
<summary>Course Prerequisites</summary>
<p>This is where the additional information goes.</p>
<!-- This can also include any other content -->

Output of the details tag example

All contributors

Looking to contribute?

Learn HTML on Codecademy