Building An Accordion Without JavaScript And CSS
HTML
07/08/2021
Gone are the days where you need to use JavaScript or an HTML and CSS hack to create an accordion. Why? Accordions are now native to HTML with solid browser support!
HTML
<details> <summary>Accordion Title</summary> <p>This will be in the accordion body.</p> <p>And this too!</p></details>
Accordion Title
This will be in the accordion body.
And this too!
The details
tag contains the content of your accordion, i.e. the expanded body. By default, it's closed. Inside of that, the summary
tag shows the heading of your accordion.