Skip to content
All referenceBlock Elements

Markdown Collapsible Section

How to create collapsible expandable sections in markdown using HTML details and summary tags. Common in GitHub READMEs.

What is markdown collapsible section?

Collapsible sections in markdown use the HTML <details> and <summary> elements. The <summary> text is always visible and acts as the toggle — clicking it expands or collapses the hidden content inside <details>. This is widely supported on GitHub and GitLab for hiding long code samples, changelogs, or optional content.

Syntax

Basic collapsible

Note the blank line after <summary> — it allows markdown to be parsed inside the block.

Result
Click to expandHidden content here.

With code block inside

Collapsible sections can contain any markdown including code blocks.

Result
See the full code(code block)

Platform support

PlatformSupportedNotes
GitHubYesFully supported in README and issues
GitLabYes
ObsidianYes
DiscordNo
NotionNo
SlackNo

Common mistakes

Wrong
No blank line after </summary>
Right
Always add a blank line after </summary> and before </details>

Without blank lines, markdown inside the details block is not parsed. The blank line signals to the parser that what follows is block-level markdown.

Tips for collapsible section

1Great for long changelogs and installation steps

Put verbose content (full changelogs, Windows-specific instructions, advanced configuration) inside collapsible sections to keep READMEs readable.

2Default open state

Add the open attribute to make the section expanded by default: <details open>.

Frequently asked questions

Everything you need to know.

1

How do I make a collapsible section in a GitHub README?

Use <details><summary>Title</summary> content </details>. Add a blank line after </summary> so markdown is parsed inside.

Related elements

Try it in the editor

Paste your markdown and see collapsible section rendered instantly with professional themes.