Xerobit
Dev Productivity

Collapsible Sections and Alerts in GitHub Markdown: details, summary and [!NOTE]

GitHub Markdown collapsible section with details and summary, the blank-line rule, [!NOTE] alert syntax, and why a section shows raw Markdown or an alert looks plain.

MA Mian Ali Khalid Updated Nov 19, 2026 7 min read
Free tool
Markdown Preview
Live Markdown preview with GitHub-flavored syntax. Tables, task lists, code blocks, strikethrough. Side-by-side editor and rendered output.
Open tool →
On this page ⌄
  1. Collapsible sections: details and summary
  2. Which collapsible variants work (rendered by GitHub, 2026-11-19)
  3. Alerts: [!NOTE] and friends
  4. Task lists, footnotes and anchors
  5. Troubleshooting table
  6. Testing your Markdown
  7. Tested

A collapsible section in GitHub Markdown is an HTML <details> element with a <summary>, and the one rule that trips everyone is: put a blank line after </summary> if you want Markdown inside to render. Alerts are blockquotes whose first line is > [!NOTE], and they only render on GitHub, not in generic Markdown renderers. Each snippet below was sent to GitHub's own renderer (POST /markdown, mode: gfm) and compared with marked 14.1.4, which powers our Markdown Preview, and with markdown-it 15.0.3. The preview tool is not GitHub; the differences are listed where they matter. On 2026-11-19 nineteen variants of the <details> markup were sent to the same endpoint, and the table below shows which ones work.

Collapsible sections: details and summary

<details>
<summary>Click to expand</summary>

Hidden content with **Markdown**, `code` and lists:

- one
- two

</details>

Three requirements, each tested:

1. A blank line after </summary>. Without it, the text that follows stays raw. This input:

<details>
<summary>More</summary>
**bold** and `code`

- item
</details>

came back from GitHub with the asterisks and backticks printed literally (the text **bold** stayed as typed), and only the list after the blank line was rendered. With a blank line between </summary> and the first Markdown line, the same text came back as <p><strong>bold</strong> and <code>code</code></p> plus the list. The reason is the HTML block rule: Markdown inside an HTML block is not processed until a blank line ends the block.

2. A blank line before </details> after a list or code block. In the version without a blank line, marked produced <li>item</details></li>: the closing tag ended up inside the list item. GitHub handled it, but a strict renderer will not. Keep the blank lines.

3. Do not indent the contents by four spaces. Inside <details>, indented lines become a code block. With body indented, GitHub returned <pre><code>body</code></pre> instead of a paragraph. If your editor auto-indents HTML, check this one.

To start expanded, add the open attribute: <details open>. GitHub rendered it as <details open=""> with the summary and body intact.

READMEs, issues, pull requests and discussions were not checked on github.com. Nested <details> work the same way, each with its own blank-line rule. For a code block inside, use a fence with a blank line before and after.

Which collapsible variants work (rendered by GitHub, 2026-11-19)

Each row is the input sent to POST https://api.github.com/markdown (mode: gfm, no token) and the HTML that came back. The syntax itself, including the blank line and the open attribute, is documented in GitHub's page Organizing information with collapsed sections. The reason for the blank line is in the GitHub Flavored Markdown spec: details and summary start an HTML block (type 6) that ends only at a blank line, so Markdown inside it is parsed only after one.

VariantWhat GitHub returned
Blank line after </summary>, Markdown body<p><strong>bold</strong> and <code>code</code></p> inside <details>: works
No blank line after </summary>the body line came back as literal text, asterisks and backticks included: raw
<summary>**Bold** summary</summary> on one line<summary>**Bold** summary</summary>: asterisks stay literal
Blank lines inside <summary> around a Markdown line with bold and code<summary> containing <p><strong>Bold</strong> and <code>code</code></p>: Markdown renders
<summary><b>Bold</b> and <code>code</code></summary>tags kept: the reliable way to format a summary
<summary><h3>Heading summary</h3></summary><h3> kept inside <summary>
<details open><details open="">
<details name="g"> on two sectionsname="user-content-g" on both: the attribute survives with a prefix
<details> with no <summary>GitHub inserted <summary>Details</summary> itself
<details style="color:red" onclick="alert(1)"> and <summary class="x" id="s1">style, onclick and class removed; id became user-content-s1
Uppercase <DETAILS> and <SUMMARY>returned as lowercase tags
Two <details> blocks on adjacent lines, each opened on one line with its <summary>both rendered
Nested <details>both levels rendered
Fenced code block insidesyntax-highlighted <div class="highlight highlight-source-js">
Pipe table insiderendered as a table
Inside a list item, indented two spaces<details> kept inside the <li>, Markdown rendered
Inside a table cell (<details><summary>S</summary>hidden</details> on one line)<details> kept in the <td>
> [!NOTE] inside <details>plain <blockquote> showing [!NOTE]: not an alert
mode: markdown instead of gfmsame output as gfm for the standard example

Two results differ from what the documentation implies. GitHub's page says the Markdown inside <summary> is supported, but a one-line <summary>**Bold**</summary> came back unrendered; it renders only when blank lines surround the content, and then GitHub wraps it in a paragraph, so HTML tags such as <b> and <code> are the safer choice for a summary. The name attribute is what makes browsers treat several <details> as an exclusive accordion; the endpoint shows it is kept, and whether github.com's pages then behave as an accordion was not checked in a browser.

Alerts: [!NOTE] and friends

> [!NOTE]
> Useful information that users should know.

> [!TIP]
> Helpful advice.

> [!IMPORTANT]
> Key information.

> [!WARNING]
> Urgent info that needs attention.

> [!CAUTION]
> Negative potential consequences.

On GitHub, [!NOTE] rendered as an alert with a "Note" title (a markdown-alert-title paragraph with an icon), likewise "Warning" and "Tip". Not every type was tested; the five names above are the ones listed in GitHub's basic writing and formatting syntax page, which also says "Alerts cannot be nested within other elements" and advises against consecutive alerts. Two alerts in a row, one NOTE and one TIP, did both render as alerts on 2026-11-19, and an alert inside <details> or inside another blockquote came back as a plain blockquote. Lowercase > [!note] also rendered as an alert, but write uppercase to match the docs.

Where they do not work:

  • In marked and markdown-it (and so in our Markdown Preview): you get a plain <blockquote> showing the literal text [!NOTE]. In marked with breaks: true the next line also got a <br>.
  • If text follows on the same line (> [!NOTE] Inline text): GitHub rendered a plain blockquote. The marker must be alone on its line.
  • Inside a list item: - item followed by an indented > [!NOTE] rendered as a plain blockquote on GitHub, not an alert. Put alerts at the top level.
  • On most other sites. Anything that does not implement GitHub's alert extension shows a blockquote. If you publish the same README on npm, a docs site or a static generator, check the output there.

A blank > line after the marker is fine: > [!TIP], >, > Tip body rendered as an alert with a body paragraph on GitHub.

Task lists, footnotes and anchors

Task lists: - [x] done and - [ ] todo. GitHub renders disabled checkboxes with accessible labels ("Completed task"). marked also renders checkboxes; markdown-it without a plugin prints [x] as text.

Footnotes: Text[^1]. plus [^1]: The note.. GitHub rendered a superscript link, a "Footnotes" section and a back-reference. marked 14 and markdown-it left it as the literal text Text[^1]. and [^1]: The note., so the preview tool will not show footnotes even though GitHub does.

Heading anchors: every heading on GitHub gets an anchor made by lowercasing, removing punctuation, and turning spaces into hyphens; repeated headings get -1, -2 suffixes. The /markdown API output does not include heading ids, so this was not verified on github.com. The rule was checked with the open-source github-slugger 2.0.0 package, which implements it:

HeadingAnchor
My Heading: v2.0 (beta)!#my-heading-v20-beta
Install (first)#install
Install (second)#install-1
C++ & Rust#c--rust
What’s new?#whats-new
API (v2)#api-v2

Relative links in a README ([guide](docs/guide.md), ![img](assets/a.png)) came back unchanged from the API (href="docs/guide.md", image wrapped in a link). GitHub resolves them against the repository when it displays the file; that was not tested on github.com. A leading / is resolved against the repository root on GitHub (not verified).

Troubleshooting table

SymptomCauseFix
**bold** or backticks show literally inside a collapsible sectionNo blank line after </summary>Add the blank line
Collapsible body shows as a monospace code blockContent indented 4 spacesRemove the indentation
</details> appears inside a list item or the section never closesNo blank line before </details>Add a blank line
Alert shows as a quote with the text [!NOTE]Renderer is not GitHub, or the alert is inside a list, or text follows the markerPut it at top level, marker alone on its line; accept the fallback elsewhere
Footnote shows as literal [^1]Renderer does not support footnotes (marked 14, markdown-it)Use GitHub, or a footnote plugin
Task list shows [x] textRenderer lacks task list support (markdown-it without plugin)Use a GFM renderer
Anchor link #my-heading does nothingAnchor differs from heading text (punctuation, duplicates)Copy the anchor from github.com or compute it as above

Testing your Markdown

Paste the snippet into the Markdown Preview to check the structure. Remember it is marked with GFM and line breaks on, so it will show alerts as quotes and footnotes as plain text. For GitHub-accurate results, use a draft issue or a gist preview. For tables, the Markdown Table Generator writes the pipe syntax for you.

Tested

2026-11-02, Node v25.8.0. GitHub's renderer was called with gh api markdown (GitHub CLI 2.87.3, mode: gfm); marked 14.1.4 with gfm: true and breaks: true; markdown-it 15.0.3 with default options (raw HTML escaped, so its details output is not a fair render). The API returns static HTML, so anything done by github.com's browser code (heading anchors, relative link resolution, Mermaid, alert icons beyond the title markup) is not verified. The five alert names were re-read in GitHub's documentation on 2026-11-19; NOTE, TIP and WARNING were rendered by the API.

2026-11-19: Python 3.11.15 with urllib posting each variant to https://api.github.com/markdown (unauthenticated, mode: gfm, one run of 26 requests). GitHub's collapsed sections page, its basic formatting syntax page and the GFM spec were read the same day. The name accordion behaviour, the collapse animation and the look of alerts on github.com were not checked in a browser.

Related tools

Written by Mian Ali Khalid. More guides in Dev Productivity.