Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hilkinr/c92f0c76efc0f563ff532131a7ec91a5 to your computer and use it in GitHub Desktop.
Save hilkinr/c92f0c76efc0f563ff532131a7ec91a5 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