Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

HTML5 New Elements – Details & Summary | HTML Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. HTML Course

Lesson 3 of 55

·HTML

HTML5 New Elements – Details & Summary

7 min

Course progress5%

What you'll learn

Keep these ideas in mind as you work through the lesson.

5 points
  • Using `<details>` and `<summary>` for collapsible content
  • Default open state with the `open` attribute
  • Accessibility benefits (native ARIA, keyboard support)
  • No‑JS alternative for simple toggles
  • Styling the disclosure indicator with CSS

Interactive Disclosure Widgets (<details> & <summary>)

The <details> element lets you create native collapsible sections without JavaScript.

<details>
  <summary>What is HTML?</summary>
  <p>HTML stands for HyperText Markup Language …</p>
</details>

How it works

  • The <summary> is always visible; clicking or pressing Enter/Space toggles the hidden content.
  • Browsers announce the open/closed state to screen readers automatically.
  • Add the open attribute (<details open>) to have the section expanded on page load.

Styling

details[open] summary::after {
  content: '▲';
  float: right;
}
summary::after {
  content: '▼';
  float: right;
}

Accessibility

  • <details> has an implicit role='group' and aria-expanded state.
  • No extra ARIA is required, but you can add aria-label to the <summary> for extra clarity.

Quick checklist for <details>

  1. <summary> present and descriptive? ✅
  2. open attribute used only when needed? ✅
  3. Content inside <details> is semantically appropriate (<p>, <ul>, etc.)? ✅
  4. Styling does not hide the disclosure triangle for assistive technology? ✅
  5. Used for non‑critical content (FAQ, TOS) rather than essential information? ✅

Tip: Use <details> for FAQs, terms of service, or any content that benefits from being optionally hidden. It works without any JavaScript.

Make it stickPractice what you've learned1 quiz · 2 practical tests · Optional activities from HTML CourseBrowse activities
Previous lessonSemantic HTML – The Structural ElementsContinue to lesson 4Forms OverviewBack to HTML Course curriculum