Collapsible sections in Markdown
Emmanuel Gautier / September 17, 2023
2 min read
Some days ago, I was facing a huge README with large example code blocks (cerberauth/openapi-oathkeeper). Those large parts in README are not interesting for every developers and some parts displayed below was not read.
As developers, we know that a well-structured markdown (like README markdown) can make a huge difference in how users and fellow developers interact with our projects. One neat way to enhance your markdown is by adding collapsible sections. These sections can help keep your markdown organized and user-friendly. In this quick guide, we'll show you how to create collapsible sections in your GitHub markdown.
You can use collapsible markdown outside Github on compatible other softwares (Gitlab, VS Code, Jupyter Notebooks, ... etc).
What are Markdown collapsible sections?
Collapsible sections, also known as "accordion" sections, allow you to hide and reveal content as needed. This can be incredibly useful when your README gets lengthy and you want to keep it clean and easily navigable.
Create a collapsible section
You can create collapsible sections in Markdown using HTML <details>
and <summary>
tags. Let's break down the example below:
<details>
<summary>Click to expand</summary>
This is the content of the collapsible section. You can include any Markdown-formatted text, lists, or code here.
</details>
Explanation:
<details>
(doc): This is the HTML tag that defines the collapsible section. It acts as a container for the content that you want to hide or reveal.<summary>
(doc): Inside the<details>
tag, you use the<summary>
tag to specify the text that users will see before expanding the section. This serves as a clickable label or button to open or close the section."Click to expand"
: This is the text that appears as the summary. You can customize it to provide a clear indication of what's hidden in the section. For example, you could use emojis, like"🔍 Click to see details."
- Content: Between the
<details>
and</details>
tags, you place the content you want to hide or reveal. This can include any Markdown-formatted text, lists, code blocks, or even other collapsible sections.
Consulting
If you're seeking solutions to a problem or need expert advice, I'm here to help! Don't hesitate to book a call with me for a consulting session. Let's discuss your situation and find the best solution together.
Related Posts
Publish on Cloudflare Pages with unsupported language versions
It may happen that a version of Node is not supported yet by Cloudflare and will remain not supported for some weeks. That can happen even if it is a Long Term Support (LTS) version. Here how to build even if cloudflare does not support the version.
Keep the same Node.js version between local environment and Github Actions
It can be complicated to have the same Node version between the local environment and the CI/CD. The latest Node.js version or the latest lts is released recently and if you want to upgrade to the Node version, usually you can forget to configure one environment.
Publish multiple projects on a Monorepo on Cloudflare Pages
All the tooling provided by service providers is great and makes the developer's life much easier. Usually, those providers connect one git repository to an application. It works fine but it is not so easy when you work on a monorepo or if you want to make multiple deployments for more than one locale from only one source code.
Featured Posts
Introducing new blog about OAuth, OpenID Connect, and IAM Solutions
I'm excited to announce the launch of a new blog named CerberAuth, where I'll be exploring the world of OAuth, OpenID Connect, and IAM solutions for modern security.
How to deal with Docker Hub rate limit on AWS
Since 2020, DockerHub has been limited to only 200 container image pull requests per six hours. This article will help you to deal with this limitation on AWS.
How to enable Python type checking in VSCode
Python now has support for type hints. In this article, we will see how to enable better IntelliSense and type checking analysis in VSCode.