Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Galadirith/87bd4d2df10485886ab1e4bfe93e9b59 to your computer and use it in GitHub Desktop.
Save Galadirith/87bd4d2df10485886ab1e4bfe93e9b59 to your computer and use it in GitHub Desktop.
How to add a collapsible section in markdown.

How to add a collapsible section in markdown.

Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
    • Qux

Some Code

function logSomething(something) {
  console.log('Something', something);
}

Code

<details>
  <summary>Click me</summary>
  
  ### Heading
  1. Foo
  2. Bar
     * Baz
     * Qux

  ### Some Code
  ```js
  function logSomething(something) {
    console.log('Something', something);
  }
  ```
</details>

Rules (If you don't do this, your code may not work)

  1. Always have an empty line after the </summary> tag
  2. Always have an empty line after each </details> tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment