Lesson 3 of 55
HTMLHTML5 New Elements – Details & Summary
7 min
Course progress5%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 3 of 55
HTML7 min
Keep these ideas in mind as you work through the lesson.
<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>
<summary> is always visible; clicking or pressing Enter/Space toggles the hidden content.open attribute (<details open>) to have the section expanded on page load.details[open] summary::after {
content: '▲';
float: right;
}
summary::after {
content: '▼';
float: right;
}
<details> has an implicit role='group' and aria-expanded state.aria-label to the <summary> for extra clarity.<details><summary> present and descriptive? ✅open attribute used only when needed? ✅<details> is semantically appropriate (<p>, <ul>, etc.)? ✅Tip: Use
<details>for FAQs, terms of service, or any content that benefits from being optionally hidden. It works without any JavaScript.