55 entries · 7 sections
Markdown Cheat Sheet
Markdown syntax with the GitHub Flavoured extensions people actually use: headings, emphasis, lists, links, code fences, tables, task lists and collapsible sections — plus what to do when a character you need is also a Markdown character.
Headings and paragraphs
| Syntax | What it does |
|---|---|
# Heading 1 | The top-level heading. Use one per document. |
## Heading 2 | Level two. Continue down to ###### for level six. |
Title on one line, ===== under it | Setext-style H1. Older syntax, still valid. |
Title on one line, ----- under it | Setext-style H2. |
A blank line | Separates paragraphs. Markdown needs the blank line; a single newline is just a space. |
Two trailing spaces | Force a line break within a paragraph. Invisible, which is why many people avoid it. |
A backslash at end of line | A line break in CommonMark and GFM, and far easier to see in a diff. |
--- | A horizontal rule. So are *** and ___ on a line of their own. |
Emphasis and inline formatting
| Syntax | What it does |
|---|---|
*italic* or _italic_ | Italic text. |
**bold** or __bold__ | Bold text. |
***bold italic*** | Both at once. |
~~strikethrough~~ | Struck-through text (GitHub Flavoured Markdown). |
`code` | Inline code, in a monospace font, with no Markdown parsed inside. |
``code with ` inside`` | Use more backticks on the outside when the code itself contains one. |
<sub>x</sub> / <sup>2</sup> | Subscript and superscript, using inline HTML. |
> quoted text | A blockquote. Nest it with >> and continue it by prefixing every line. |
Lists
| Syntax | What it does |
|---|---|
- item | A bullet list. * and + work too, but pick one and stay with it. |
1. item | A numbered list. |
1. on every line | Still renders 1, 2, 3 — which keeps diffs clean when you insert an item. |
Indent by two spaces | Nest a list under its parent item. |
- [ ] todo and - [x] done | Task list checkboxes (GFM). On GitHub they are clickable in issues. |
A blank line between items | Turns a tight list into a loose one, which adds paragraph spacing. |
An indented paragraph under an item | Continue a list item with more than one block, including code fences. |
Term, then a line starting with : | A definition list. Not in CommonMark, but supported by many processors. |
Links and images
| Syntax | What it does |
|---|---|
[text](https://example.com) | An inline link. |
[text](https://example.com "Title") | A link with a title shown on hover. |
[text][ref] plus [ref]: https://example.com | A reference-style link. Keeps long URLs out of the prose. |
<https://example.com> | An autolink, rendered as a clickable URL. |
 | An image. The alt text is not optional if you care about accessibility. |
[](https://example.com) | An image that is also a link — how badges are made. |
[text](#section-heading) | Link to a heading on the same page: lower-cased, spaces turned into hyphens, punctuation dropped. |
[text](./other.md) | A relative link to another file in the same repository. |
Code blocks
| Syntax | What it does |
|---|---|
``` on its own line | Opens and closes a fenced code block. |
```js | A fenced block with syntax highlighting for that language. |
Four-space indent | The older indented code block. It works, but fences are clearer and support language hints. |
```diff with + and - lines | Renders as a coloured diff. |
~~~ instead of ``` | Tildes also work as fences, which helps when the content contains backticks. |
Four backticks | Fence a block that itself contains a three-backtick fence. |
```mermaid | Renders a diagram on GitHub, GitLab and many other viewers. |
Tables (GitHub Flavoured)
| Syntax | What it does |
|---|---|
| a | b | | One table row, cells separated by pipes. |
| --- | --- | | The separator line under the header. It is required — no separator, no table. |
| :-- | | Left-align that column. |
| :-: | | Centre-align that column. |
| --: | | Right-align that column. |
\| | Escape a pipe that belongs to the cell's content. |
Ragged source columns | The widths in your source do not matter; only the number of pipes does. |
Escaping, HTML and front matter
| Syntax | What it does |
|---|---|
\*not italic\* | Backslash-escape a Markdown character to show it literally. |
! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ | Every ASCII punctuation character — all 32 of them — and nothing else. The shorter list quoted in a lot of places is original Markdown's, not CommonMark's. |
\a or \3 | Not escapes. Before anything that is not ASCII punctuation the backslash is printed as typed — except at the end of a line, where it is a line break. |
\* inside `code` | Escapes do nothing in code spans, code blocks, autolinks or raw HTML. There the backslash stays. |
<br> | Inline HTML is allowed in most Markdown flavours, including GitHub's. |
<details><summary>More</summary> ... </details> | A collapsible section. Leave a blank line before the inner Markdown or it will not render. |
<!-- comment --> | A comment that never appears in the rendered output. |
and other entities | HTML entities work, which is how you get characters Markdown would otherwise eat. |
--- at the very top of a file | Opens a YAML front-matter block in static site generators such as Jekyll, Hugo and Astro. |
Worth knowing
- There is no single Markdown. CommonMark is the strict specification, GitHub Flavoured Markdown adds tables, task lists, strikethrough and autolinks, and every other renderer sits somewhere nearby. If a table or a checkbox does not render, the processor probably only implements CommonMark.
- Heading anchors are generated from the heading text: lower-cased, spaces replaced with hyphens, and most punctuation removed. That is why [jump](#getting-started) links to ## Getting Started, and why renaming a heading silently breaks every link pointing at it.
- Inside a <details> block, leave a blank line after the </summary> tag before your Markdown. Without it GitHub treats the content as raw HTML and your lists and code fences come out as plain text.
Try a snippet instead of reading about it
Reference is faster when you can run the thing. Paste a snippet into AltF Code, the free in-browser editor — real syntax highlighting for HTML, CSS, JavaScript, Python, SQL, JSON and more, with HTML, CSS and JavaScript running live in the preview. No install and no sign-up.
Open the editorMarkdown — common questions
- How do I add a line break in Markdown?
- End the line with two spaces, or with a backslash, and follow it with a newline. A single newline on its own is treated as a space and the lines are joined into one paragraph. For a new paragraph rather than a line break, leave a completely blank line between them.
- How do I show a backtick or an asterisk literally?
- Escape it with a backslash: \* for an asterisk, \_ for an underscore. For a backtick, wrap the text in a longer run of backticks than it contains — ``a ` b`` renders the inner backtick as text. Inside a fenced code block nothing is interpreted at all.
- Does Markdown support tables?
- Not in the original specification or in plain CommonMark, but GitHub Flavoured Markdown does, and so do GitLab, most static site generators and most note apps. Rows are pipe-separated and the header must be followed by a separator line of dashes, with optional colons to set the column alignment.
- Can I use HTML inside Markdown?
- Yes in most flavours, including GitHub's — inline tags such as <br>, <sub> and <kbd> work, as do block elements like <details> and <table>. Some renderers sanitise or strip HTML for security, and inside a block-level HTML element you often need a blank line before Markdown syntax will be parsed again.