Example of Accordion Components and FAQs without using JavaScript
Description
With the new "details" and "summary" element tags, it has become simpler, more semantic, and accessible to develop an Accordion and FAQs (Frequently Asked Questions) component without using JavaScript.
Attributes
- Open
- This is a boolean attribute that, when declared on the
<details>element, displays the content inside the<details>. When not present, it hides the content. By default, this attribute is absent and does not display the "details".
You can use this attribute on more than one<details>element at a time, but when thename="example"attribute values are the same across<details>elements, it only works for the first element with the attribute declared. - Name
- This attribute groups several
<details>elements, allowing only one of them to be opened at a time. This functionality makes the UI and component behave similarly to an accordion.
FAQs
- Question 1
- Question 2
- Question 3
Answer
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab doloribus magni dolorum fugiat maxime corrupti suscipit officiis sequi. Porro nesciunt, amet magnam aliquid odio eaque non est rerum labore ducimus!