Skip to content

<details> - Disclosure Widget

Interactive HTML5

The <details> element creates a native disclosure widget where users can show or hide additional information. It provides built-in toggle functionality without requiring JavaScript, making it perfect for FAQs, expandable sections, and progressive disclosure patterns.

Result
<details>
<summary>Click to expand</summary>
Hidden content goes here...
</details>
AttributeValueDescription
openBooleanWhen present, the details are visible (expanded)

The <details> element supports all global attributes.

The open attribute controls the initial state of the disclosure widget:

Result
Result
Result
Result
Result

The disclosure marker (triangle/arrow) can be styled or hidden:

Result

The <details> element fires a toggle event when opened or closed:

Result

Create an accordion where only one item is open at a time:

Result

Add smooth animations to the details element:

Result

The <details> element has excellent built-in accessibility:

  • Enter/Space: Toggle open/closed when summary is focused
  • Tab: Move focus to next interactive element
Result
  1. Descriptive summaries: Make summary text clear and actionable
  2. Keyboard accessible: Ensure all functionality works with keyboard
  3. Focus indicators: Provide clear focus styles
  4. ARIA labels: Add additional context when needed
  5. Logical structure: Use proper heading hierarchy inside details
Result
Result

Excellent Support

The <details> element is supported in all modern browsers:

  • Chrome: 12+ (2011)
  • Firefox: 49+ (2016)
  • Safari: 6+ (2012)
  • Edge: 79+ (2020)
  • Opera: 15+ (2013)
  • Mobile: Widely supported

Fallback: For older browsers, content inside <details> will be visible by default. Consider using a polyfill or JavaScript solution for critical functionality.

  • <summary> - Defines the visible heading for details
  • <dialog> - Modal and non-modal dialogs
  • <menu> - Context menus
  1. Always include <summary>: Required for proper functionality
  2. Make summaries descriptive: Users should know what they’ll reveal
  3. Don’t nest too deeply: Keep hierarchy simple and navigable
  4. Consider mobile users: Ensure touch targets are large enough
  5. Test keyboard navigation: All functionality must work without mouse
  6. Provide context: Use ARIA labels when summary text isn’t enough
  7. Style focus states: Make keyboard navigation clear
  8. Avoid overuse: Too many collapsed sections can be overwhelming

Learn More: