Skip to main content
cheat sheetsyntaxreference

Markdown Cheat Sheet: Syntax, Examples & GFM Reference

Copy Markdown syntax for headings, lists, links, images, code, tables, and task lists, with clear CommonMark and GitHub Flavored Markdown labels.

By mdkit Team···6 min read
On this page

Use # for headings, **text** for bold, - for bullets, [text](url) for links, and backticks for code. The sections below separate portable CommonMark syntax from GFM extensions such as tables and task lists.

Copy an example, then test it in your target renderer because raw HTML, math, footnotes, and other extensions vary. For GFM details, see GitHub Flavored Markdown syntax.

Headings

# H1 — Page title ## H2 — Major section ### H3 — Sub-section #### H4 — Deeper ##### H5 ###### H6

Use one descriptive page title when your publishing system expects it, then nest headings without skipping levels. A logical hierarchy improves navigation for assistive technology and human readers.

An alternative "Setext" style exists for H1 and H2 but it's rarely used:

Page Title ========== Section -------

Emphasis

*italic* or _italic_ **bold** or __bold__ ***bold italic*** ~~strikethrough~~ (GFM) ==highlight== (extension — not universal)

Renders as: italic, bold, bold italic, strikethrough.

Lists

Unordered

- First item - Second item - Nested (2 spaces) - Another nested - Third item

You can use -, *, or +. Pick one consistently, and indent nested items enough for their parent marker and renderer.

Ordered

1. First 2. Second 3. Third

Many renderers continue numbering after the first marker, so repeated 1. markers are convenient:

1. First 1. Second 1. Third

The starting number can matter: a list beginning with 3. may render with a start value of 3. Preview when numbering carries meaning.

Task lists (GFM)

- [x] Completed task - [ ] Pending task - [ ] Another todo

Widely supported on GitHub, GitLab, Obsidian, Notion, and most modern editors.

[Link text](https://example.com) [Link with title](https://example.com "Hover title") <https://example.com> — autolink <[email protected]> — autolink email
See [mdkit blog][1] and [the cheat sheet][cheatsheet] for more. [1]: https://mdkit.io/blog [cheatsheet]: https://mdkit.io/blog/markdown-cheat-sheet

Images

![Alt text](path/to/image.jpg) ![Alt text](image.jpg "Title shown on hover")

Reference-style also works:

![Alt][logo] [logo]: /images/logo.png

Write meaningful alt text for informative images and empty alt text for decorative images.

[![Alt text](thumb.jpg)](https://example.com)

Code

Inline code

Use `code` for inline snippets, file names like `README.md`, or short identifiers.

Fenced code blocks with language

```javascript const greet = (name) => `Hello, ${name}!`; ``` ```python def greet(name): return f"Hello, {name}!" ``` ```bash npm install example-package ```

The language tag enables syntax highlighting in GitHub, static site generators, and most Markdown viewers.

Indented code blocks (legacy)

Prefix with four spaces:

No language highlighting here. Just plain monospace.

Fenced blocks are strongly preferred.

Blockquotes

> A single-line quote. > A multi-line > blockquote just works. > **With formatting** inside quotes. > > Even multiple paragraphs.

Nested quotes

> Outer quote > > > Inner quote > > Back to outer

Tables (GFM)

| Name | Role | Price | | :------ | :--------: | ----: | | Alice | Admin | $200 | | Bob | Editor | $50 | | Charlie | Viewer | $10 |

Alignment is set by the colons in the separator row:

  • :--- → left
  • :---: → center
  • ---: → right

Tips: you don't need to align the pipes manually; most editors do it for you. Need a no-typing-required table? Try the Markdown Table Generator.

Horizontal rule

---

Three or more hyphens, asterisks, or underscores on their own line. Use sparingly — usually an H2 is a better section break.

Escaping special characters

Prefix with a backslash:

\*not italic\* \# not a heading \`not code\`

Escapable characters: \ ` * _ {} [] () # + - . ! |.

Line breaks

  • Paragraph break: one blank line between paragraphs.
  • Soft line break: a normal newline inside a paragraph; renderers commonly display it as a space.
  • Hard line break: end a line with two spaces or a backslash, then newline.
  • HTML break: <br> works only when the renderer allows raw HTML.

HTML inside Markdown

CommonMark defines raw HTML blocks and inline HTML, but applications may disable, escape, or sanitize them:

<kbd>Ctrl</kbd> + <kbd>C</kbd> to copy. <details> <summary>Click to expand</summary> Hidden content goes here. </details> <sub>subscript</sub> and <sup>superscript</sup>

Some platforms (like GitHub comments) sanitize dangerous tags. Always test.

GFM extensions

GitHub Flavored Markdown adds these on top of CommonMark:

URLs become clickable automatically:

Visit https://mdkit.io — no brackets needed.

Task lists

(Covered above.)

Strikethrough

~~This is struck out.~~

Tables

(Covered above.)

Footnotes (Pandoc / some processors)

Here's a claim that needs a source.[^1] [^1]: Source details here.

Not universal — check your renderer.

Math (KaTeX / MathJax — extension)

Inline: $E = mc^2$ Block: $$ \sum_{i=1}^{n} i = \frac{n(n+1)}{2} $$

Supported by GitHub, Obsidian, many static site generators. Not part of CommonMark.

Diagrams (Mermaid — extension)

```mermaid graph TD A[Start] --> B[Write Markdown] B --> C{Valid?} C -->|Yes| D[Ship it] C -->|No| B ```

Supported by GitHub, GitLab, Notion, Obsidian.

Comments

Markdown has no native comment syntax. Use HTML:

<!-- This won't render. Useful for editor notes. -->

Front matter (YAML)

Used by static site generators (Hugo, Jekyll, Next.js MDX, Astro):

--- title: "My Post" date: "2026-02-04" tags: ["markdown", "guide"] --- Post content starts here.

The --- fences delimit the metadata block. Most renderers strip it before display.

Quick reference card

WhatHow
Heading# H1 to ###### H6
Bold**text**
Italic*text*
Strikethrough~~text~~
Link[text](url)
Image![alt](url)
Code (inline)`code`
Code block```lang```
Blockquote> text
Unordered list- item
Ordered list1. item
Task list- [ ] / - [x]
Table| col | col | + separator row
Horizontal rule---
Line breaktwo trailing spaces

Where to go next

Knowing the syntax is step one. Step two is actually writing good documentation. A few directions:

Keep the syntax simple, preview in the destination renderer, and add extensions only when the audience can render them.

Frequently Asked Questions

Is Markdown a programming language?+
No. Markdown is a lightweight markup language — a plain-text format that converts to HTML. It has no logic, loops, or variables. You write it, a Markdown processor (like marked, commonmark, or GitHub's renderer) converts it to HTML for display.
What's the difference between CommonMark and GitHub Flavored Markdown?+
CommonMark specifies core Markdown, including fenced code blocks and optional info strings. Formal GFM adds tables, task list items, strikethrough, extended autolinks, and tag filtering.
Do all Markdown editors support the same syntax?+
Core syntax is broadly supported, but parsers still differ in edge cases and extensions. Use CommonMark where portability matters and test the exact target renderer.
How do I write a line break in Markdown?+
End a line with two spaces, then press Enter. Or insert a blank line between paragraphs. Some processors also accept a trailing backslash (\) for a forced break.
Can I use HTML inside Markdown?+
CommonMark defines raw HTML, but applications can disable, escape, or sanitize it. Check the target renderer before relying on elements such as <kbd>, <details>, or <sup>.

Keep reading