# Markdown Cheatsheet A quick reference for Markdown syntax. This file is itself written in Markdown, so you can open it in any editor or previewer to see the rendered result next to the raw syntax. > Covers CommonMark plus widely supported extensions (GitHub Flavored Markdown). Extensions are marked **(GFM)**; support varies by app. --- ## Headings ```markdown # Heading 1 ## Heading 2 ### Heading 3 #### Heading 4 ##### Heading 5 ###### Heading 6 ``` > Tip: leave a blank line before and after headings, and put a space after the `#`. --- ## Text Formatting | Style | Syntax | Result | |-------|--------|--------| | Bold | `**bold**` or `__bold__` | **bold** | | Italic | `*italic*` or `_italic_` | *italic* | | Bold + italic | `***both***` | ***both*** | | Strikethrough (GFM) | `~~text~~` | ~~text~~ | | Inline code | `` `code` `` | `code` | | Highlight (some apps) | `==text==` | ==text== | | Subscript (some apps) | `H~2~O` | H~2~O | | Superscript (some apps) | `X^2^` | X^2^ | --- ## Paragraphs and Line Breaks Separate paragraphs with a blank line: ```markdown First paragraph. Second paragraph. ``` Force a line break within a paragraph by ending a line with **two spaces** or a **backslash**: ```markdown Line one·· Line two Line one\ Line two ``` (`··` above stands for two trailing spaces.) --- ## Lists ### Unordered ```markdown - Item - Item - Nested item (indent 2 or 4 spaces) - Nested item * Asterisks work too + So do plus signs ``` ### Ordered ```markdown 1. First 2. Second 3. Third 1. Nested 2. Nested ``` > The actual numbers don't matter to most renderers: `1. 1. 1.` still renders as 1, 2, 3. ### Multi-paragraph list items ```markdown 1. First item Indented paragraph belongs to the first item. 2. Second item ``` --- ## Links ```markdown [Inline link](https://example.com) [Link with title](https://example.com "Hover title") (auto-link) [Reference link][ref] [Relative link](../docs/guide.md) [Jump to section](#headings) [ref]: https://example.com "Optional title" ``` --- ## Images ```markdown ![Alt text](path/to/image.png) ![Alt text](path/to/image.png "Optional title") ![Alt text][img-ref] [img-ref]: path/to/image.png ``` Clickable image (image inside a link): ```markdown [![Alt text](image.png)](https://example.com) ``` --- ## Blockquotes ```markdown > A quote. > > A second paragraph in the same quote. > > > A nested quote. ``` --- ## Code ### Inline ```markdown Use `printf()` to print. Use ``code with a ` backtick`` inside double backticks. ``` ### Fenced code blocks Use three backticks (or three tildes) and an optional language for syntax highlighting: ````markdown ```python def hello(): print("Hello, world!") ``` ```json { "name": "example" } ``` ~~~bash echo "tildes work too" ~~~ ```` To show a code fence *inside* a code block, wrap it in a longer fence (four backticks), as this cheatsheet does. ### Indented code block Indent every line by 4 spaces (or 1 tab): ```markdown This is a code block. No language highlighting here. ``` --- ## Horizontal Rules Any of these on their own line (with blank lines around): ```markdown --- *** ___ ``` --- ## Tables (GFM) ```markdown | Left | Center | Right | |:-----|:------:|------:| | a | b | c | | 1 | 2 | 3 | ``` Renders as: | Left | Center | Right | |:-----|:------:|------:| | a | b | c | | 1 | 2 | 3 | - Colons in the separator row control alignment. - Pipes don't need to line up; it just looks nicer. - Escape a literal pipe inside a cell with `\|`. --- ## Task Lists (GFM) ```markdown - [x] Done - [ ] Not done - [ ] Also not done ``` - [x] Done - [ ] Not done - [ ] Also not done --- ## Footnotes Supported by many renderers (GitHub, Pandoc, many static-site generators): ```markdown Here is a statement with a footnote.[^1] [^1]: This is the footnote text. ``` --- ## Escaping Characters Put a backslash before a character to show it literally: ```markdown \*not italic\* \# not a heading 1\. not a list ``` Characters you can escape: ``` \ ` * _ {} [] () # + - . ! | < > ``` --- ## HTML in Markdown Most renderers allow inline HTML for things Markdown can't do: ```markdown
Click to expand Hidden content here. Markdown works inside if separated by blank lines.
Press Ctrl + C to copy.
``` Press Ctrl + C to copy.
Click to expand Hidden content here.
--- ## Tips - **Blank lines matter.** Put one before and after headings, lists, code blocks, tables, and blockquotes. - **Stay consistent.** Pick `-` or `*` for bullets and stick with it. - **Name your code fences.** Adding a language (`js`, `python`, `bash`, ...) enables syntax highlighting. - **Use relative links** for files in the same repo so they keep working when it's cloned. - **Preview as you go.** VS Code (`Ctrl/Cmd+Shift+V`), Obsidian, Typora, and GitHub all render Markdown live. - **Renderer differences.** Tables, task lists, footnotes, highlight, and sub/superscript aren't part of original Markdown; check what your target app supports. --- *Save this file as `markdown-cheatsheet.md` and keep it handy.*