Basic details and summary syntax
Wrap the hidden content in <details>, and put a <summary> element first to act as the label. Readers see only the label with a small arrow until they click it.
<details>
<summary>Click to expand</summary>
Hidden content goes here. **Markdown** works
because of the blank line above.
- Lists
- Images
- Code blocks
</details>Why the blank line matters
Under CommonMark rules, an HTML block runs until the next blank line, and everything in it is passed through as raw HTML. Without a blank line after </summary>, the text that follows is still part of that HTML block, so **bold** and - list markers appear literally. The blank line ends the HTML block and switches the parser back to Markdown. Put another blank line before </details> for the same reason.
<details>
<summary>Broken</summary>
**This stays literal**
</details>
<details>
<summary>Fixed</summary>
**This renders bold**
</details>Open by default
Add the open attribute to show the content expanded when the page loads. Readers can still collapse it.
<details open>
<summary>Installation steps</summary>
1. Download the file
2. Run the installer
</details>Code blocks and nested sections
Fenced code blocks work inside details as long as they are surrounded by blank lines. Sections can also be nested, which is handy for long changelogs or FAQ lists in a README. Do not indent the content by four spaces, because indentation turns it into an indented code block.
<details>
<summary>Show the config</summary>
```json
{ "theme": "github", "pageSize": "a4" }
```
<details>
<summary>Advanced options</summary>
Nested content.
</details>
</details>When to collapse content
Collapsible sections keep a README or issue scannable without deleting detail. Good candidates are long logs and stack traces in bug reports, full configuration files, optional platform-specific install steps, screenshots that support but do not drive the text, and the answers in an FAQ. Keep anything a reader needs on a first pass (the summary, the quick-start command, warnings) visible, because many readers never expand a section.
<details>
<summary>Full error log</summary>
```text
Error: ENOENT: no such file or directory
at Object.openSync (node:fs:601:3)
```
</details>Where collapsible sections work
Support depends on whether the renderer allows raw HTML. Platforms that strip HTML need their own feature instead.
| Platform | details/summary | Alternative |
|---|---|---|
| GitHub | Yes: READMEs, issues, PRs, comments, wikis | - |
| GitLab | Yes, Markdown inside with blank lines | - |
| Obsidian | Renders, but Markdown inside HTML is not processed | Foldable callout: > [!note]- |
| VS Code preview | Yes | - |
| Notion | No HTML | Toggle block: type > then space |
| No HTML | Spoiler: >!hidden text!< | |
| Discord | No HTML | Spoiler: ||hidden text|| |
| Hugo | Only with markup.goldmark.renderer.unsafe = true | - |
Common pitfalls
Missing blank lines are the number one cause of broken dropdowns. Others: putting text before <summary> (the label must come first), using Markdown formatting inside the summary itself (it sits inside the HTML block, so use <b> or <code> tags there instead), and indenting the content, which creates a code block. Also remember that in PDF or print output there is nothing to click, so collapsible content is a web-only feature.
Frequently Asked Questions
How do I make a dropdown in Markdown?
Use HTML: <details><summary>Label</summary> followed by a blank line, your content, another blank line, and </details>. Markdown itself has no dropdown or toggle syntax.
How do I hide a section in a GitHub README?
Wrap it in <details> with a <summary> label. GitHub renders it as a collapsed section that readers can expand. To hide text completely, so it never displays, use an HTML comment instead: <!-- hidden -->.
Why isn’t Markdown rendering inside my details block?
You are missing the blank line after </summary> (and before </details>). Without it, the parser treats the content as raw HTML and shows the Markdown symbols literally.
Do collapsible sections work in Obsidian or Notion?
Obsidian displays details blocks but does not parse Markdown inside HTML, so a foldable callout ("> [!note]- Title") works better. Notion ignores HTML; type > followed by a space to create a toggle block instead.
Try it live
Paste this syntax into the free markdown to html converter and see the rendered output instantly. No signup, and everything runs in your browser.
Open Markdown to HTML Converter →