4 min read
ā¢Question 29 of 49easyWhat is the Details/Summary Element?
Native accordion without JavaScript.
What You'll Learn
- Creating expandable content
- Native accordion pattern
- Styling options
Basic Usage
index.htmlHTML
<details>
<summary>Click to expand</summary>
<p>This content is hidden until clicked.</p>
</details>Open by Default
index.htmlHTML
<details open>
<summary>Already expanded</summary>
<p>This content is visible initially.</p>
</details>FAQ Pattern
index.htmlHTML
<details>
<summary>What is your return policy?</summary>
<p>You can return any item within 30 days.</p>
</details>
<details>
<summary>Do you ship internationally?</summary>
<p>Yes, we ship to over 100 countries.</p>
</details>Styling
styles.cssCSS
details {
border: 1px solid #ddd;
padding: 10px;
}
summary {
cursor: pointer;
font-weight: bold;
}Use Cases
- FAQs
- Expandable sections
- Advanced options
- Any show/hide pattern