Creating a Collapsible Header in Markdown (.md) Files

Creating a collapsible section in a Markdown file is relatively simple, provided you can add an appropriate title to the collapsible section. The default syntax is as follows:

<details>
<summary>Section Title Text</summary>
</details>

Let’s put that into a more practical example:

<details>
<summary>Header-Like Text</summary>
Collapsible section introduction text

## Additional Content (heading)
More context about this section
</details>

The problem is the styling and formatting of the section. By embedding a header (h1, h2, h3, h4, etc.) tends to add a line between the collapse symbol and the header. So to get around this, I played around with styling the text as a header. I used the bold and underline tags as well as the font tag which allows us to manipulate the font size:

<details>
<summary><b><u><font size="+1">Header-Like Text</font></u></b></summary>
Collapsible section introduction text

## Additional Content (heading)
More context about this section
</details>
Author: Jacqui Muller

Feel free to reach out or browse through:


Leave a Reply

Up ↑

%d bloggers like this: