HTML <summary> Tag

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Interactive Content

What You’ll Learn

The <summary> tag provides the clickable label for <details> disclosure widgets. This guide covers syntax, pairing with details, FAQ patterns, styling, and accessibility for beginners.

01

Disclosure Label

Visible heading for hidden content.

02

With details

Must live inside details.

03

No JavaScript

Native toggle behavior.

04

FAQ Sections

Question labels for answers.

05

Styling

class & global attributes.

06

Best Practices

Concise, descriptive labels.

What Is the <summary> Tag?

The <summary> tag is an HTML element used with <details> to create an interactive disclosure widget. It serves as the heading or brief description for content hidden inside details, giving users a concise overview they can click to expand.

First child of details

Place summary as the first element inside details. The browser renders it as the clickable toggle control for the hidden content that follows.

No JavaScript is required — browsers handle expand and collapse natively, making summary ideal for FAQs, optional content, and clean UI design.

📝 Syntax

Embed summary inside opening and closing details tags:

syntax.html
<details>
  <summary>Your summary here</summary>
  <!-- Hidden content here -->
</details>

With Hidden Content

details-summary.html
<details>
  <summary>Show More</summary>
  <p>Your additional content goes here.</p>
</details>

Syntax Rules

  • summary must be the first child of details for correct behavior.
  • Self-closing syntax (<summary />) is not valid in HTML.
  • Write concise, descriptive label text so users know what will be revealed.
  • Only one summary per details element.

⚡ Quick Reference

TopicCode SnippetNotes
Basic pair<details><summary>...</summary>Required parent
FAQ question<summary>How does it work?</summary>Question label
Styled labelclass="highlight"Global attr
Open by default<details open>On parent
vs detailssummary = labeldetails = widget
Browser supportModern browsersIE limited

⚖️ <summary> vs <details>

ElementRoleNotes
<summary>Clickable label / headingAlways inside details
<details>Disclosure containerHolds summary + hidden content
Attributesopen, name on detailssummary uses global attrs only
JavaScriptNot requiredNative browser toggle

🧰 Attributes

The <summary> tag has no tag-specific attributes. Use global attributes like class and id for styling and customization.

attributes.html
<details>
  <summary class="highlight">Your Styled Summary</summary>
  <p>Hidden content here.</p>
</details>
class / id Global

Hook for CSS styling the disclosure label.

class="highlight"
style Global

Inline color or font-weight for the summary label.

style="color: #dc2626"
title Optional

Advisory tooltip for extra context on the label.

title="Click to expand"
open (on details) Parent

Expand content by default using open on the parent details element.

<details open>

Examples Gallery

Styled labels, expand/collapse toggles, and FAQ questions with copy-ready code and live previews.

👀 Live Preview

Click the summary to toggle hidden content:

What is HTML?

HTML structures content on the web using elements like headings, paragraphs, and links.

📚 Common Use Cases

Use <summary> to label expandable content in details widgets for FAQs, optional sections, and compact page layouts.

Styled Summary

Apply a class to customize the appearance of the summary label:

attributes.html
<details>
  <summary class="highlight">Your Styled Summary</summary>
  <p>This is the hidden content that appears when you click the summary.</p>
</details>
Try It Yourself

Expanding and Collapsing Content

The primary purpose of summary is to let users expand and collapse content within details:

expanding.html
<details>
  <summary>Show More</summary>
  <p>Your additional content goes here.</p>
</details>
Try It Yourself

FAQ Sections

The details and summary combination is often used for FAQ sections, letting users reveal answers to specific questions:

faq-sections.html
<details>
  <summary>How does it work?</summary>
  <p>Explanation of how it works...</p>
</details>
Try It Yourself

♿ Accessibility

  • Write descriptive labels — Summary text should clearly describe the hidden content.
  • Keyboard accessible — Users can focus and activate summary with keyboard (Enter/Space).
  • Meaningful pairing — Ensure the revealed content relates directly to the summary label.
  • Do not hide critical info — Essential content should not require discovery behind a collapsed panel.

🧠 How <summary> Works

1

Author adds summary inside details

The label is the first child of details.

Markup
2

Browser renders toggle control

Summary appears as a clickable disclosure triangle or marker.

UI
3

User clicks to expand

Hidden content inside details is shown or hidden.

Interaction
=

Compact, interactive content

Users explore additional information at their own pace without JavaScript.

Browser Support

The <summary> tag is fully supported in all modern browsers. Legacy Internet Explorer has partial or no support.

Baseline · HTML5

Native disclosure widgets

Modern browsers render <summary> with built-in expand/collapse behavior.

98% Modern browser support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
Internet Explorer Partial / no support
Partial support
Opera Fully supported
Full support
<summary> tag 98% — modern browsers

Bottom line: Use <summary> with <details> confidently in all modern browsers.

Conclusion

Mastering the <summary> tag empowers you to create interactive, user-friendly disclosure widgets. Combined with <details>, it offers a seamless native experience for FAQs and expandable content without JavaScript.

💡 Best Practices

✅ Do

  • Keep summary content concise and descriptive
  • Place summary as the first child of details
  • Ensure a meaningful relationship between label and hidden content
  • Test across browsers for consistent toggle behavior

❌ Don’t

  • Use summary outside of details
  • Hide essential information only behind collapsed panels
  • Write vague labels like “Click here” without context
  • Add multiple summary elements in one details

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <summary>

Bookmark these before you build disclosure widgets.

6
Core concepts
📦 02

details

Required parent.

Pairing
03

No JS

Native toggle.

Behavior
04

FAQs

Q&A labels.

Use case
🎨 05

class

Style labels.

Attributes
🌐 06

Modern

98% support.

Compatibility

❓ Frequently Asked Questions

It provides the visible, clickable label for a details disclosure widget. Users click summary to show or hide the content below.
No. summary must be inside details as its first child to function correctly.
No. Browsers provide native expand and collapse when summary is paired with details.
No. Use global attributes like class, id, and style.
Yes in all modern browsers. Internet Explorer has partial or no support for details and summary.

Build disclosure widgets

Practice <summary> with <details> for FAQs and toggle content in the Try It editor.

Try Show More example →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful