Coastal Media Brand

The  HTML <details> element represents a “disclosure widget” from which the user can obtain additional information or controls. It allows you to create collapsible sections of content on a webpage, providing an interactive way to hide or reveal content as needed.


The basic syntax for the <details> element is as follows:

  <summary>Click to toggle</summary>
  <!-- Content to be revealed or hidden -->

The <details> element should contain a <summary> element as its first child. The content to be revealed or hidden is placed after the <summary> element and can be marked up like most normal content; a <p>, a <div>, an <img>, and so on.


Here’s a simple example with barely any styling at all. It shows how the <details> element can be used, with two <summary> elements, each revealing a <p> when clicked:

Here’s a second example, with slightly more HTML markup, in order to make styling with CSS slightly easier. This demo is taken from Jemima Abu’s tutorial How to Build an HTML Accordion (No CSS or JavaScript!)


The <details> element supports the following attributes:

  • open: specifies that the details should be visible when the page loads. This attribute doesn’t require a value, and can be included like so: <details open>


The <details> element can contain HTML content like text, images, lists, tables, and more. You can include valid HTML elements within the <details> element to provide the desired content that will be revealed or hidden.

Did You Know?

  • The <details> element is commonly used to create collapsible sections, such as frequently asked questions (FAQs), additional information sections, or spoiler content.
  • When using the <details> element, the summary should be concise and clearly indicate what will be revealed or hidden when clicked.
  • You can style the appearance of the disclosure widget using CSS to customize its visual presentation.


By default, the <summary> element uses the text cursor. Consider changing this to a pointer cursor to show the user that this is an interactive element.

details summary {
  cursor: pointer;

Learn More

Web Design Myrtle Beach

Coastal Media Brand

© 2024 Coastal Media Brand. All rights Reserved.