<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/the-details-element-collapsing-content-without-the-hassle-jsomzzfak" -->

---
title: The details element, collapsing content without the hassle
description: An overview of the native HTML details/summary element as an alternative to JavaScript-based collapse libraries, covering basic markup, browser support, custom...
canonical: https://daily.dev/posts/the-details-element-collapsing-content-without-the-hassle-jsomzzfak
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The details element, collapsing content without the hassle | daily.dev
og:description: An overview of the native HTML details/summary element as an alternative to JavaScript-based collapse libraries, covering basic markup, browser support, custom...
og:url: https://daily.dev/posts/the-details-element-collapsing-content-without-the-hassle-jsomzzfak
og:image: https://api.daily.dev/og/posts/jSOMzzFAK.png
og:image:alt: The details element, collapsing content without the hassle
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The details element, collapsing content without the hassle

**[utilitybend](https://daily.dev/sources/utilitybend)** · 5 min read · 0 upvotes · 0 comments

## Summary

An overview of the native HTML details/summary element as an alternative to JavaScript-based collapse libraries, covering basic markup, browser support, custom styling with CSS (including a custom toggle icon), the limitations around animating the collapse, and how to build a simple accordion by removing the open attribute from sibling details elements with a small JS snippet.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://utilitybend.com/blog/the-details-element-collapsing-content-without-the-hassle>

## Questions this post answers

### How do I create a collapsible section in HTML without using JavaScript?

Use the native details and summary elements: wrap your content in a details tag with a summary tag as the clickable title. The section is closed by default and toggles open when the summary is clicked; add the open attribute to have it expanded initially. This works with great browser support (except Internet Explorer and pre-2020 Edge) and requires no JS or ARIA attributes for basic accessibility.

_daily.dev surfaces practical HTML and CSS techniques for developers cutting unnecessary JS from their UI._

### How can I build an accordion (only one section open at a time) using the details element?

Group multiple details elements inside a wrapper, then add a small JavaScript snippet that listens for clicks on each details element and removes the open attribute from its sibling details elements. This keeps only one section expanded at a time while still relying on native details/summary markup for the toggle behavior itself, rather than a full accordion library.

_Developers comparing lightweight accordion approaches can track patterns like this via daily.dev._

### Why do developers still use JavaScript libraries instead of the native details element for collapsing content?

Mainly because animating the open/close transition is difficult with a pure CSS approach on the native details element; JS-based collapse libraries make smooth height animations easier to achieve. Workarounds exist to mimic a typical animated collapse feel, but they do not fully replicate library-based animations, which is why many developers still reach for JS solutions despite the native element's good support and built-in accessibility.

_daily.dev helps developers weigh native HTML features against JS libraries when picking UI solutions._

## Similar posts on daily.dev

- [Replacing JS with just HTML](https://daily.dev/posts/replacing-js-with-just-html-63nvjchya) · Hacker News · 12 upvotes · 1 comments
- [An Over-The-Top Spoiler Design with the Details Element – Frontend Masters Blog](https://daily.dev/posts/an-over-the-top-spoiler-design-with-the-details-element-frontend-masters-blog-0uqzmubnn) · Frontend Masters · 1 upvotes · 0 comments
- [NoLoJS: Reducing the JS Workload with HTML and CSS](https://daily.dev/posts/nolojs-reducing-the-js-workload-with-html-and-css-qok6dvopl) · Web Performance Calendar · 3 upvotes · 0 comments
- [Use cases for aria-expanded](https://daily.dev/posts/use-cases-for-aria-expanded-tgq9kcgth) · Piccalilli · 6 upvotes · 0 comments

---

Tags: [#css](https://daily.dev/tags/css), [#html](https://daily.dev/tags/html), [#accessibility](https://daily.dev/tags/accessibility)

[View this post on daily.dev](https://daily.dev/posts/the-details-element-collapsing-content-without-the-hassle-jsomzzfak)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"The details element, collapsing content without the hassle","url":"https://daily.dev/posts/the-details-element-collapsing-content-without-the-hassle-jsomzzfak","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/the-details-element-collapsing-content-without-the-hassle-jsomzzfak"},"datePublished":"2026-09-20T07:43:19.756Z","dateModified":"2026-09-20T07:43:41.868Z","description":"An overview of the native HTML details/summary element as an alternative to JavaScript-based collapse libraries, covering basic markup, browser support, custom...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/50b505bf867fc19693db76a44f712a7c?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/50b505bf867fc19693db76a44f712a7c?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"utilitybend","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"utilitybend","logo":"https://media.daily.dev/image/upload/s--hONVFSz4--/f_auto,q_auto/v1789890196/logos/utilitybend?_a=BAMAMicg0","url":"https://daily.dev/sources/utilitybend"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/the-details-element-collapsing-content-without-the-hassle-jsomzzfak","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"css,html,accessibility","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"utilitybend","item":"https://daily.dev/sources/utilitybend"},{"@type":"ListItem","position":3,"name":"The details element, collapsing content without the hassle"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/the-details-element-collapsing-content-without-the-hassle-jsomzzfak#faq","mainEntity":[{"@type":"Question","name":"How do I create a collapsible section in HTML without using JavaScript?","acceptedAnswer":{"@type":"Answer","text":"Use the native details and summary elements: wrap your content in a details tag with a summary tag as the clickable title. The section is closed by default and toggles open when the summary is clicked; add the open attribute to have it expanded initially. This works with great browser support (except Internet Explorer and pre-2020 Edge) and requires no JS or ARIA attributes for basic accessibility. daily.dev surfaces practical HTML and CSS techniques for developers cutting unnecessary JS from their UI."}},{"@type":"Question","name":"How can I build an accordion (only one section open at a time) using the details element?","acceptedAnswer":{"@type":"Answer","text":"Group multiple details elements inside a wrapper, then add a small JavaScript snippet that listens for clicks on each details element and removes the open attribute from its sibling details elements. This keeps only one section expanded at a time while still relying on native details/summary markup for the toggle behavior itself, rather than a full accordion library. Developers comparing lightweight accordion approaches can track patterns like this via daily.dev."}},{"@type":"Question","name":"Why do developers still use JavaScript libraries instead of the native details element for collapsing content?","acceptedAnswer":{"@type":"Answer","text":"Mainly because animating the open/close transition is difficult with a pure CSS approach on the native details element; JS-based collapse libraries make smooth height animations easier to achieve. Workarounds exist to mimic a typical animated collapse feel, but they do not fully replicate library-based animations, which is why many developers still reach for JS solutions despite the native element's good support and built-in accessibility. daily.dev helps developers weigh native HTML features against JS libraries when picking UI solutions."}}]}
```

