Skip to content

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.

A collapsed table (click the summary in the preview)
Markdown
<details>
<summary>Supported versions (3 rows)</summary>

| Version | Released   | Status      |
| ------- | ---------- | ----------- |
| 3.2     | 2026-09-14 | Current     |
| 3.1     | 2026-05-02 | Security    |
| 3.0     | 2025-11-20 | End of life |

</details>

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 expanded
Markdown
<details open>
<summary>Supported versions</summary>

| Version | Released   | Status      |
| ------- | ---------- | ----------- |
| 3.2     | 2026-09-14 | Current     |
| 3.1     | 2026-05-02 | Security    |
| 3.0     | 2025-11-20 | End of life |

</details>

Nested 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:

Nested collapsible tablesMarkdown
<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:

Collapse syntax by tool
ToolSyntaxNotes
GitHub, GitLab, VS Code, Docusaurus<details> + <summary>Blank lines around the table
Obsidian> [!note]- calloutPrefix 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
Quartocollapse="true" calloutHTML output
NotionToggle blockAdd 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:

Obsidian: collapsed callout with a tableMarkdown
> [!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:

MkDocs: collapsible admonition (pymdownx.details)Markdown
??? 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:

MkDocs: <details> with md_in_htmlMarkdown
<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):

kramdown: parse Markdown inside <details>Markdown
<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:

Quarto: collapsed calloutMarkdown
::: {.callout-note collapse="true"}
## Supported versions

| Version | Status  |
| ------- | ------- |
| 3.2     | Current |
:::

Collapsible tables by platform

Collapsible tables by platform
Platform<details> rendersTable inside renders
GitHub (GFM)READMEs, issues, PRs, comments and wikis.YesYes: Blank line after </summary>
GitLab (GLFM)YesYes: Blank line after </summary>
VS Code previewYesYes
ObsidianMarkdown inside HTML isn’t rendered. Use a foldable callout.YesNo: Use > [!note]-
MkDocs (Python-Markdown)YesPartly: md_in_html or pymdownx.details
Jekyll / GitHub Pages (kramdown)YesPartly: Add markdown="1"
DocusaurusYesYes: Blank lines around the table
HugoRaw HTML is dropped unless markup.goldmark.renderer.unsafe is true.Partly: Needs unsafe: trueYes
Pandoc / QuartoHTML output only. Quarto also has collapsible callouts.Partly: HTML outputYes
NotionPut a table inside a toggle block instead.No: Use a toggle blockNot applicable
Reddit, Slack, DiscordNoNo

✅ supported · ⚠️ partly or with a workaround · ❌ not supported · Last verified October 2026

Common mistakes and fixes

No blank line after the summary

Broken: the table prints as raw textMarkdown
<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