Collapsible Tables in Markdown with <details>
By MarkdownTables.com editorial teamUpdated
On this page
How do I make a collapsible table in Markdown?
Markdown has no collapse syntax of its own, but GitHub, GitLab and most renderers that allow HTML accept the HTML <details> element. Everything inside it except the <summary> is hidden until the reader clicks the summary line.
Copy the whole block. The blank lines around the table are required.
Mentioning the row count or the main takeaway in the summary (“3 rows”, “all tests pass”) tells readers whether it's worth opening.
Why the blank lines matter
Under CommonMark rules, a line starting with <details> opens an HTML block that runs until the next blank line, and everything in an HTML block is passed through as raw HTML. If the table follows </summary> directly, its lines are part of that HTML block and show up as plain pipes. The blank line ends the HTML block so the table is parsed as Markdown. The blank line before </details> keeps the closing tag from being read as part of the table.
Don't indent the table to make the source look nested: four or more spaces turn it into a code block.
Expanded by default, nesting and summary text
Expanded by default
Add open to show the table on page load while still letting readers collapse it:
<details open> starts expandedNested sections
A <details> block can contain others, for example one table per operating system under a single heading. Each inner block follows the same blank-line rules:
<details>
<summary>Benchmarks</summary>
<details>
<summary>Linux</summary>
| Test | Time |
| ----- | -----: |
| Build | 41 s |
| Tests | 2.3 min |
</details>
<details>
<summary>Windows</summary>
| Test | Time |
| ----- | -----: |
| Build | 58 s |
| Tests | 3.1 min |
</details>
</details>Formatting the summary
The summary line is HTML, so Markdown inside it isn't reliable. Use tags: <summary><b>Results</b> (12 rows)</summary> or <code> for file names. To make the summary look like a heading, put <h3> inside it; GitHub allows that, but it adds a heading to the page outline.
Obsidian, MkDocs, Jekyll and Quarto
Where plain <details> doesn't parse the table inside, each tool has its own collapse syntax:
| Tool | Syntax | Notes |
|---|---|---|
| GitHub, GitLab, VS Code, Docusaurus | <details> + <summary> | Blank lines around the table |
| Obsidian | > [!note]- callout | Prefix every table line with > |
| MkDocs (Material) | ??? note "Title" | pymdownx.details; indent the table |
| MkDocs (any theme) | <details markdown> | md_in_html extension |
| Jekyll / GitHub Pages | <details markdown="1"> | Or parse_block_html: true in _config.yml |
| Quarto | collapse="true" callout | HTML output |
| Notion | Toggle block | Add the table inside the toggle |
Obsidian: foldable callouts
Obsidian shows the <details> toggle but doesn't render Markdown inside HTML, so the table appears as raw text. A callout with a - after the type is collapsed by default (+ starts it open), and tables inside callouts render:
> [!note]- Supported versions
> | Version | Status |
> | ------- | ----------- |
> | 3.2 | Current |
> | 3.0 | End of life |MkDocs
Python-Markdown doesn't parse Markdown inside raw HTML. With Material for MkDocs, the usual choice is a collapsible admonition from pymdownx.details, with the table indented four spaces:
??? note "Supported versions"
| Version | Status |
| ------- | ----------- |
| 3.2 | Current |
| 3.0 | End of life |To keep plain <details> markup, enable the md_in_html extension and add the markdown attribute:
<details markdown>
<summary>Supported versions</summary>
| Version | Status |
| ------- | ------- |
| 3.2 | Current |
</details>Jekyll and GitHub Pages
The same README can render on github.com and break on a GitHub Pages site: kramdown doesn't parse Markdown inside HTML blocks unless told to. Add markdown="1" (GitHub ignores the attribute):
<details markdown="1">
<summary>Supported versions</summary>
| Version | Status |
| ------- | ------- |
| 3.2 | Current |
</details>Quarto
Quarto's callouts take a collapse option, which works in HTML output:
::: {.callout-note collapse="true"}
## Supported versions
| Version | Status |
| ------- | ------- |
| 3.2 | Current |
:::Collapsible tables by platform
| Platform | <details> renders | Table inside renders |
|---|---|---|
| GitHub (GFM)READMEs, issues, PRs, comments and wikis. | Yes | Yes: Blank line after </summary> |
| GitLab (GLFM) | Yes | Yes: Blank line after </summary> |
| VS Code preview | Yes | Yes |
| ObsidianMarkdown inside HTML isn’t rendered. Use a foldable callout. | Yes | No: Use > [!note]- |
| MkDocs (Python-Markdown) | Yes | Partly: md_in_html or pymdownx.details |
| Jekyll / GitHub Pages (kramdown) | Yes | Partly: Add markdown="1" |
| Docusaurus | Yes | Yes: Blank lines around the table |
HugoRaw HTML is dropped unless markup.goldmark.renderer.unsafe is true. | Partly: Needs unsafe: true | Yes |
| Pandoc / QuartoHTML output only. Quarto also has collapsible callouts. | Partly: HTML output | Yes |
| NotionPut a table inside a toggle block instead. | No: Use a toggle block | Not applicable |
| Reddit, Slack, Discord | No | No |
✅ supported · ⚠️ partly or with a workaround · ❌ not supported · Last verified October 2026
Common mistakes and fixes
No blank line after the summary
<details>
<summary>Supported versions</summary>
| Version | Status |
| ------- | ------- |
| 3.2 | Current |
</details>Fix it by adding an empty line after </summary> and before </details>, as in the first example.
Other things to check
- Unclosed tags. A missing
</details>hides the rest of the document inside the section. - Inside a list. Indent the whole block to the list item's content column, but by fewer than four extra spaces, or the table becomes code.
- The table itself is invalid. A collapsed table fails for the same reasons as any other. Check it with the table validator before wrapping it.
When to collapse a table, and when not to
Collapse tables that support the text but aren't needed to follow it: full benchmark results, long changelogs, option references, test matrices. Leave the main table of a page visible, because collapsed content is easy to miss, and say what's inside in the summary.
If the table is long because it's wide, a transposed table or a narrower column set may help more than hiding it; see column width. For the table rules themselves, see Markdown table syntax, and for a short key–value table that needs no header, see headerless tables.
Frequently asked questions
How do I make a collapsible table on GitHub?
Wrap it in <details>: put <details> and <summary>Title</summary> on their own lines, leave a blank line, add the Markdown table, leave another blank line, then close with </details>. GitHub renders a click-to-expand section in READMEs, issues, pull requests and comments.
Why does my table show as raw pipes inside <details>?
There is no blank line between </summary> and the table. Without it, the table lines are treated as part of the HTML block and printed as text. Add an empty line after </summary> and another before </details>.
How do I make a collapsible section open by default?
Add the open attribute: <details open>. The section starts expanded and readers can still collapse it. GitHub, GitLab and other HTML-capable renderers support it.
Can I nest collapsible sections?
Yes. Put a complete <details>…</details> block inside another one, with blank lines around each table and each inner block. Keep nesting shallow; two levels is usually the limit before readers lose track.
Does <details> work in Obsidian?
The toggle works, but Obsidian doesn’t render Markdown inside HTML, so the table shows as text. Use a foldable callout instead: start the callout with > [!note]- and prefix every table line with > .
Can I make a table collapsible in MkDocs?
Yes. With pymdownx.details, write ??? note "Title" and indent the table four spaces under it. Or enable md_in_html and add the markdown attribute to <details> so Python-Markdown parses the table inside.
Generate the table, then paste it between the blank lines.
Open the table generator