Markdown Guide
Write clean, portable documents β headings, emphasis, lists, links, images, code blocks, tables, blockquotes, GitHub Flavored Markdown, front matter and ready-to-use README recipes. Every code block has a Copy button.
Copy button on each code block Β· β Beginner β Intermediate β Advanced01 Introduction β Plain Text That Renders
Markdown is a lightweight markup language that lets you write formatted documents in plain text. You add a few symbols β # for a heading, ** for bold, - for a list β and any Markdown-aware tool renders it into clean HTML, a PDF, a slide deck, or a documentation site.
The point is readability: a Markdown file is perfectly understandable even before it is rendered. Compare that to HTML, where a paragraph is buried in <p> tags, and the value becomes obvious.
Where you will meet Markdown
- README files on GitHub, GitLab and Bitbucket
- Issues, pull requests and comments β every major code host
- Documentation β MkDocs, Docusaurus, Hugo, Jekyll, Astro, VitePress
- Notes apps β Obsidian, Notion, Bear, Joplin, Logseq
- Chat & forums β Slack, Discord, Reddit, Stack Overflow
- Books, blogs and slides β Pandoc, Marp, reveal.js
The two dialects you need to know
- CommonMark β the strict, unambiguous core specification. Everything else is built on it.
- GitHub Flavored Markdown (GFM) β CommonMark plus tables, task lists, strikethrough, autolinks, footnotes and alerts. This is what GitHub, and most people, actually use.
02 Setup & Editors Beginner
Your first file β no build step needed
Create a file ending in .md (or .markdown) and start typing. That is the entire setup.
# My First Markdown File
This is a paragraph. Markdown turns it into a `<p>` on render.
## Why it works
- Plain text, so it survives every editor and every decade
- Portable β GitHub, VS Code and Pandoc all read the same file
- Optional: **bold**, *italic*, `code`, [links](https://example.com)
Editors & live preview
The Markdown pipeline
Almost every tool follows the same three steps. Knowing them explains most βwhy didn't my formatting work?β moments.
- Write β you author a plain-text
.mdfile - Parse β a Markdown parser (marked, markdown-it, remark, cmark) builds a syntax tree
- Render β the tree becomes HTML, a static page, a PDF or slides
03 Headings & Paragraphs Beginner
ATX headings β the hash style
Prefix a line with # symbols. One hash is an H1, two is an H2, up to six for H6. Always put a space after the hashes.
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
# H1 per document β it is the document's title. Use H2 for major sections and H3 for subsections. Never skip a level just to get a smaller font.Setext headings β the underline style
A less common alternative for the first two levels. The number of = or - characters does not need to match the text length.
Heading 1
=========
Heading 2
---------
---) can be read as a Setext H2 or a horizontal rule, depending on context. Prefer the # style to avoid ambiguity.Paragraphs & line breaks
A block of text with no blank line inside is a single paragraph. Separate paragraphs with one blank line.
This is the first paragraph.
It continues on the next line β still one paragraph.
This is a second paragraph, because of the blank line above.
To force a line break within a paragraph, end the line with two spaces or a backslash.
Line one with two trailing spacesΒ·Β·
Line two (new line, same paragraph)
Line one with a backslash\
Line two (same effect, easier to see)
\ for hard breaks and configure their editor's trim trailing whitespace setting β otherwise a formatter silently removes the spaces and the break disappears.04 Emphasis, Strikethrough & Rules Beginner
Inline emphasis
*italic* or _italic_
**bold** or __bold__
***bold and italic***
~~strikethrough~~
`inline code`
Mix and nest them freely, but keep markers balanced: **_bold italic_** renders as bold italic.
snake_case_name will not italicise the middle β good. But _foo_bar_ can behave differently across parsers. When in doubt, use * for emphasis.Horizontal rules
Three or more -, * or _ on their own line, optionally with spaces between, draw a divider.
---
***
___
What is not in the core spec
- Underline β there is no native underline; use
<u>text</u>HTML if you truly need it. - Highlight β no standard syntax; some notes apps accept
==text==. - Sub / superscript β not in core; some parsers accept
~sub~and^sup^.
05 Lists & Task Lists Beginner
Unordered lists
Start each item with -, * or +. Pick one and stay consistent.
- Apples
- Oranges
- Bananas
Ordered lists
Numbered items. The first number sets the start; later numbers are cosmetic β Markdown renumbers automatically.
1. Wake up
2. Coffee
3. Write Markdown
Nested lists
Indent child items by two to four spaces under the parent.
- Frontend
- HTML
- CSS
- JavaScript
- Backend
1. Node.js
2. Python
Task lists (GFM)
Use - [ ] for an open task and - [x] for a completed one. GitHub renders these as real checkboxes.
- [x] Write the outline
- [x] Draft the introduction
- [ ] Add code examples
- [ ] Request review
<p> per item). Add blank lines and the list becomes βlooseβ, wrapping each item in a paragraph. Both are valid β loose lists just add vertical space.06 Links, Images & Badges Beginner
Inline links
[OpenAI](https://openai.com)
[OpenAI](https://openai.com "Visit OpenAI")
The text in square brackets is what readers see; the URL is in parentheses. An optional quoted string becomes the tooltip title.
Reference links
Define the URL once and reuse it β ideal for documents that link to the same place many times.
See the [documentation][docs] and the [changelog][log].
[docs]: https://example.com/docs
[log]: https://example.com/changelog "Release notes"
Autolinks
<https://example.com>
<mailto:hello@example.com>
GFM also linkifies bare URLs: https://example.com
Images
An image is a link with a leading !. The text in brackets is the alt text, shown if the image fails to load and read aloud by screen readers.


Linking an image
Wrap an image inside a link to make it clickable β the classic pattern for a logo that leads home.
[](https://example.com)
[](https://ci.example.com)
07 Code & Syntax Highlighting Beginner
Inline code
Wrap short snippets in single backticks. Use double backticks to include a literal backtick inside.
Use `npm install` to install dependencies.
To show a backtick: `` `code` ``
Fenced code blocks
Surround a block with three backticks (or tildes). Add a language name after the opening fence to enable syntax highlighting.
```js
function greet(name) {
return `Hello, ${name}!`;
}
```
Indented code blocks (legacy)
Indenting four spaces also creates a code block, but fenced blocks are clearer and support highlighting. Prefer fences.
This is an indented code block.
It still works, but has no language hint.
Highlighting inside a block
Once you name the language, the renderer colours keywords, strings and comments β no extra markup required.
```python
def add(a, b):
"""Return the sum of two numbers."""
return a + b
```
Diff blocks
Use the diff language to show added and removed lines with colour.
```diff
- old line that was removed
+ new line that was added
unchanged context line
```
js, ts, py, html, css, bash, json, yaml, sql, diff and text. Use text when you want no highlighting at all.08 Blockquotes & Callouts Intermediate
Blockquotes
Start a line with > to create a blockquote. Stack them to nest, and leave a > on a blank line to keep a single quote spanning multiple paragraphs.
> Markdown is a text-to-HTML conversion tool.
> It is written in plain text.
> Nested quotes:
>
> > A quote inside a quote.
GitHub alerts
GFM recognises five callout types when you start a blockquote with a special tag. GitHub renders each with its own colour and icon.
> [!NOTE]
> Useful information users should know.
> [!TIP]
> Helpful advice for doing things better.
> [!IMPORTANT]
> Key information users need to achieve their goal.
> [!WARNING]
> Urgent info that needs immediate attention.
> [!CAUTION]
> Advises about risks or negative outcomes.
Collapsible sections
Raw HTML <details> works on GitHub and most renderers β perfect for long logs or optional detail.
<details>
<summary>Click to expand</summary>
Hidden content goes here, including lists and code.
</details>
[!NOTE] syntax renders as an alert on GitHub but appears as an ordinary blockquote elsewhere. Other apps have their own callout syntax β check your renderer.09 Tables Intermediate
Tables are a GFM extension. Separate columns with pipes |. The first row is the header; the second row of dashes sets the alignment of each column.
| Syntax | Description | Example |
| :---------- | :-------------------: | ------------: |
| Bold | Makes text bold | `**text**` |
| Italic | Makes text italic | `*text*` |
| Strikethrough | Crosses out text | `~~text~~` |
Column alignment
Escaping pipes and adding line breaks
A literal pipe inside a cell must be escaped as \|. Tables cannot hold real multi-line cells β use <br> for a break.
| Expression | Result |
| ---------- | ---------- |
| `a \| b` | bitwise OR |
| Line one<br>Line two | two lines |
10 Escaping & Raw HTML Intermediate
Escaping special characters
Put a backslash before a character you want to display literally instead of it being interpreted as Markdown.
\*not italic\*
\# not a heading
\- not a list item
\`not code\`
These are the escapable characters: \ ` * _ { } [ ] ( ) # + - . ! | >
Raw HTML
Most renderers pass through inline HTML, which is useful for the few things Markdown cannot express.
This is <u>underlined</u> and this is H<sub>2</sub>O.
<div align="center">A centred block</div>
Comments
<!-- This comment is invisible in the rendered output -->
html language tag so the parser treats it as text, not markup.11 GitHub Flavored Markdown Advanced
GFM is CommonMark plus the features that make Markdown feel like a platform: tables, task lists, strikethrough, autolinks, footnotes and alerts. It is the dialect used across GitHub, and the one most people mean by βMarkdownβ.
Footnotes
Markdown is portable.[^1] It also scales to whole books.[^book]
[^1]: A reference is rendered as a superscript number.
[^book]: Pandoc can turn Markdown into EPUB and PDF.
Emoji
Ship it :rocket: Nice work :tada: Looks good :+1:
Mentions, issues & references
Thanks @octocat β this closes #42 and supersedes commit a1b2c3d.
On GitHub, @user notifies a person, #123 links to an issue or PR, and a commit SHA links to the commit.
Everything GFM adds at a glance
12 Front Matter & Metadata Advanced
Front matter is a block of metadata at the very top of a file, fenced by three dashes. Static site generators, blog engines and documentation tools read it to set titles, dates, tags and layouts. It is not part of the rendered body.
YAML front matter (most common)
---
title: Getting Started
description: A short summary used for SEO and previews.
date: 2026-01-15
author: Laksh
tags: [guide, markdown, docs]
draft: false
---
TOML front matter
Hugo users often prefer TOML, fenced with +++.
+++
title = "Getting Started"
date = 2026-01-15
tags = ["guide", "markdown"]
+++
Who consumes it
- Jekyll β YAML front matter, the original convention
- Hugo β YAML, TOML or JSON front matter
- Astro / Eleventy β front matter drives layouts and routing
- MkDocs / Docusaurus β page titles, sidebar order, tags
--- block just shows up as a horizontal rule plus text.13 README & Documentation Recipes Intermediate
A README is the front door of a project. This is a proven skeleton you can copy and fill in.
# Project Name
> One-line description of what this project does and who it is for.
[](https://ci.example.com)
[](LICENSE)
## Features
- Fast and dependency-free
- Works with any Markdown renderer
- Accessible by default
## Installation
```bash
npm install project-name
```
## Usage
```js
import { project } from "project-name";
project();
```
## Contributing
Pull requests are welcome. Please open an issue first.
## License
MIT
A table of contents, generated by hand
Anchor links point at the lowercased, hyphenated heading text. Most editors (or Markdown All in One) can generate this list for you.
## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)
Collapsing the long parts
<details>
<summary>Roadmap</summary>
- [ ] v1.0 β core release
- [ ] v1.1 β theming
- [ ] v2.0 β plugins
</details>
14 Cheat Sheet & Best Practices Beginner
Syntax at a glance
Best practices
- Blank lines between blocks. When formatting breaks, this is almost always why.
- One H1 per document, then H2 and H3 in order β never skip levels.
- Write meaningful alt text for every image.
- Fence code with a language so it highlights and stays readable.
- Prefer reference links when a URL repeats many times.
- Stay portable: use core CommonMark + tables + links unless you know the target renderer supports more.
- Preview before you commit β Ctrl+Shift+V in VS Code catches most mistakes in seconds.
.md file is scannable and clean, it will render well almost everywhere.