Getting Started
Headers & Paragraphs
Use # for headers (1-6 levels). Alternative syntax uses === for H1 and --- for H2. Paragraphs need a blank line between them. Markdown is designed to be readable as plain text.
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
Alternative Heading 1
=====================
Alternative Heading 2
---------------------
This is a paragraph. Just write
plain text. Leave a blank line
between paragraphs.Line Breaks
Two trailing spaces or a backslash at the end of a line create a hard line break (<br>). Without them, a single newline is a soft wrap that joins into one paragraph. Always leave a blank line to separate paragraphs.
First line
Second line (two trailing spaces above)
Or use a backslash at end of line\
to force a line break.
Soft wrap without break:
just continue on the next line
and it joins into one.Comments
Markdown has no official comment syntax, but HTML comments (<!-- -->) work in most renderers and are hidden in output. The [//]: # trick uses an empty link reference to add notes. Comments are still visible in the raw source.
<!-- HTML comments work in most Markdown -->
[//]: # (This is a comment)
[//]: # "Another comment style"
<!--
Multi-line comment
not rendered in output
-->Whitespace & Indentation
Four leading spaces turn text into a code block — beware accidental indentation. Indentation matters for nested lists (2-4 spaces per level). Tabs are usually treated as 4 spaces. Use spaces consistently to avoid rendering issues across parsers.
Paragraph one.
This is an indented code block
because of 4 spaces.
> Quoted text needs > prefix.
Three spaces is just text
(less than 4).Horizontal Rules
Three or more hyphens, asterisks, or underscores create a horizontal rule (<hr>). Hyphens are most common. Spaces between characters are allowed. For clarity, put blank lines around horizontal rules. Avoid confusing --- (rule) with # (heading).
---
***
___
* * *
Text above
---
Text belowText Formatting
Bold & Strong
Double asterisks or underscores produce bold (<strong>). Asterisks are preferred since underscores do not work mid-word (snake_case). You can nest other emphasis inside bold. HTML <strong> tags work as a fallback.
**bold text**
__also bold__
**bold with *italic* inside**
<strong>HTML bold also works</strong>
**bold**Italic & Emphasis
Single asterisks or underscores create italic (<em>). Asterisks work mid-word; underscores treat word-internal underscores as literal (so no_italic_here). Use <em> as a fallback. Italic is for emphasis, not just styling.
*italic text*
_also italic_
*italic*
<em>HTML italic</em>
normal *italic* normalBold + Italic Combined
Triple asterisks/underscores produce both bold and italic. You can also nest them: bold containing italic or vice versa. Order does not matter for rendering but should be consistent for readability.
***bold and italic***
___also both___
**_bold and italic_**
*__bold and italic__*
combine **bold** and *italic*Strikethrough
Double tildes (~~) create strikethrough, part of GitHub Flavored Markdown and now widely supported. The HTML <del> and <s> tags are equivalent fallbacks. Standard (original) Markdown does not include strikethrough.
~~strikethrough~~
~~crossed out text~~
<del>HTML delete</del>
<s>HTML strikethrough</s>
~~done~~ and ~~pending~~Mark / Highlight
Double equals (==) for highlighting is an extension supported by some parsers (not in GFM core). The HTML <mark> tag works universally. Use highlighting sparingly to draw attention to key terms — overuse reduces its effect.
==highlighted text==
<mark>HTML mark</mark>
This is ==important== text.
Compare **bold**, *italic*, ==mark==.Subscript & Superscript
Tilde (subscript) and caret (superscript) syntax (~ ~ and ^ ^) are extensions not in standard Markdown or GFM — supported by Pandoc, R Markdown, and a few others. For universal support, use HTML <sub> and <sup> or Unicode characters.
H~2~O is water
E = mc^2^
x^2^ + y^2^ = r^2^
1st^st^ January
CO~2~ emissionsLists
Unordered Lists
Use -, *, or + for unordered list items — pick one and be consistent (- is most common). Indent 2-4 spaces for nested items. Mixing markers in the same list can cause issues in some parsers. One item per line.
- item one
- item two
- item three
* asterisk works too
+ plus sign also works
- sub-item (indent 2 spaces)
- another sub-itemOrdered Lists
Ordered lists use numbers followed by periods. The actual numbers do not need to be sequential — Markdown renumbers them. To start at a specific number, use that number first (10. starts at 10). Use 1. for all items to auto-number.
1. first
2. second
3. third
1. auto-numbered
1. still increments
1. third item
10. starts at 10
11. nextNested Lists
Indent nested list items by 2-4 spaces (4 is safest for mixed types). You can mix ordered and unordered lists at different levels. Deep nesting (3+ levels) hurts readability — consider restructuring. Keep indentation consistent.
1. top level
- nested unordered
- second nested
2. back to top
1. nested ordered
2. another
3. third top
- fruits
- apple
- granny smith
- bananaTask Lists
Task list syntax (- [x] and - [ ]) is a GitHub Flavored Markdown extension. The checkbox renders as interactive on GitHub/GitLab. Works with both ordered and unordered lists. Great for READMEs, issue trackers, and progress tracking.
- [x] completed task
- [ ] incomplete task
- [ ] another todo
1. [x] done
2. [ ] not done
- [x] Write the docs
- [ ] Review PR
- [ ] DeployLoose vs Tight Lists
If list items are separated by blank lines, the list is 'loose' (each item wrapped in <p>). Without blank lines, it is 'tight' (no <p> wrappers). This affects spacing in HTML output. Add blank lines deliberately to control paragraph wrapping.
- tight item
- tight item
- tight item
- loose item
- loose item
- loose itemList with Multiple Paragraphs
To include multiple paragraphs or block elements in a list item, indent the continuation by 4 spaces (or align with the list marker content). Blank lines separate the sub-blocks. This is essential for complex list structures but easy to get wrong.
- First item
Second paragraph of first item.
- Second item
> A blockquote inside a list item.
>
> Must be indented to align.
- Third itemLinks
Inline Links
Inline links use [text](url). Optional title in quotes appears as a tooltip on hover. Relative links work for internal site navigation. Anchor links (#id) jump to elements with matching id. The URL must not contain spaces — use %20 for spaces.
[link text](https://example.com)
[link with title](https://example.com "Title here")
[relative link](/about)
[anchor](#section-id)Reference Links
Reference links keep text readable by separating the URL. Define references anywhere in the document ([ref]: url). Reference definitions are not rendered. The implicit form [text][] uses the text itself as the reference id. References can be reused.
[link text][ref]
[ref]: https://example.com "Optional title"
[link text][1]
[1]: https://example.com
[link text]
[link text]: https://example.comAuto Links & URLs
Bare URLs are auto-linked in GitHub Flavored Markdown. For standards compliance, wrap URLs in angle brackets (<url>). The angle-bracket form works in all Markdown flavors. Auto-linking can be disabled in some parsers.
https://example.com
<https://example.com>
<http://www.google.com>
Auto-linking bare URLs is supported
in GFM: visit https://example.com now.Email Auto Links
Email addresses in angle brackets become clickable mailto: links. The original Markdown spec supported the <text@domain> form. Some renderers obfuscate email addresses to reduce spam harvesting. Use a contact form for better spam protection on public sites.
<[email protected]>
Contact: <[email protected]>
<John Doe <[email protected]>>
Mailto links work in most renderers.Link Titles
Link titles appear as tooltips on hover. Use double or single quotes around the title. Titles are optional and purely for UX/SEO hints. They do not replace link text — screen readers may ignore them. Keep titles concise.
[hover for title](https://example.com "Example Site")
[reference with title][a]
[a]: https://example.com "Example Site"
[title with single quotes](https://example.com 'Single')Internal & Anchor Links
Heading anchors are auto-generated from heading text (lowercased, spaces to hyphens, punctuation removed) in most parsers. For custom IDs, use HTML <a id="..."> or the {#id} attribute extension (Pandoc/marked). Anchor links are essential for tables of contents.
## Section Heading
[jump to Section](#section-heading)
[back to top](#top)
<a id="custom-id"></a>
[custom anchor](#custom-id)
## Heading {#explicit-id}Images
Basic Image
Image syntax is like links but prefixed with !. The alt text is required for accessibility — it describes the image for screen readers and shows if the image fails to load. The path can be relative, absolute, or a URL. Title is optional.


Image with Alt Text
Alt text should be meaningful and concise — describe the image's purpose, not just 'image'. For decorative images, an empty alt (alt='') is acceptable to tell screen readers to skip it. Never use 'image of' or 'picture of' — screen readers already announce it.


Linked Images
Wrap an image in a link by nesting image syntax inside link syntax: [](url). Common for thumbnails that link to full-size versions, badges that link to CI status, and logos that link to home. Keep alt text describing the destination, not just the image.
[](https://example.com/full)
[](/)
[](https://ci.example.com)Reference Images
Reference images use the same reference style as links, prefixed with !. Define the image reference once and reuse it. Useful when the same image appears multiple times or to keep image-heavy paragraphs readable.
![alt text][img-ref]
[img-ref]: https://example.com/image.png "Title"
![alt][logo]
[logo]: /assets/logo.pngImage Dimensions & Figure
Standard Markdown has no image sizing syntax — use HTML <img> with width/height attributes. Percentage widths enable responsive sizing. The <figure> + <figcaption> combo provides semantic captions (HTML5). Some extended Markdown (Pandoc) supports {width=300}.
<img src="image.png" width="300" height="200" alt="sized image">
<img src="banner.png" width="100%" alt="responsive">
<figure>
<img src="diagram.png" alt="flowchart">
<figcaption>Figure 1: System flow</figcaption>
</figure>Inline Code & Escaping
Inline Code
Wrap inline code in single backticks. To show backticks inside code, use double backticks as the delimiter (or more). Inline code renders in monospace and is not parsed as Markdown. Great for filenames, commands, and code identifiers.
Use the `printf()` function.
Inline code: `const x = 42;`
Code with backticks: ``use `code` here``
A `<div>` element.Escaping Backticks in Code Spans
To include a backtick inside a code span, use more backticks as the delimiter than appear inside: double backticks around a single backtick. Outside code spans, escape a backtick with a backslash. The closing fence must match the opening length.
To show a backtick inside code,
use more backticks as delimiters:
`` ` `` one backtick
`` a`b `` backtick inside text
Use \ to escape outside code:
A literal backtick: \`Code Spans & Whitespace
Code spans preserve internal whitespace exactly. A common trick: wrap content with a single leading/trailing space to display leading/trailing spaces that would otherwise be trimmed. One space on each side is stripped automatically.
` spaced ` (spaces preserved)
` code ` with one space pad
`function f() { return; }`
` multi word code `Backslash Escapes
Backslash escapes special Markdown characters: backtick, asterisk, underscore, curly braces, square brackets, parentheses, hash, plus, minus, dot, exclamation, and the backslash itself. Escaping renders the character literally. Only escape characters that would otherwise be interpreted as formatting.
\*not italic\*
\_not italic\_
\#not a heading
\[not a link](url)
\`not code\`
\\backslash itself
\!not an imageCharacters to Escape
These are the escapable characters in Markdown. Not all need escaping everywhere — # only matters at line start, - in list context, and so on. When in doubt, escape. Curly braces and parentheses usually only need escaping in specific contexts (links, template strings).
\\ backslash
\` backtick
\* asterisk
\_ underscore
\{ \} curly braces
\[ \] square brackets
\( \) parentheses
\# hash
\+ plus
\- minus
\. dot
\! exclamationCode Blocks
Indented Code Blocks
Indenting by 4 spaces (or a tab) creates a code block. Indented code blocks lack syntax highlighting and a language tag. They cannot be used inside list items (treated as continuation). Prefer fenced code blocks for new content — indented blocks are legacy.
Normal paragraph.
// indented code (4 spaces)
function hello() {
console.log("hi");
}
Back to normal text.Fenced Code Blocks
Triple backticks or triple tildes create fenced code blocks. Fences are preferred over indented blocks — they are unambiguous and support language hints. Tildes (~~~) are useful when the code itself contains triple backticks. Always close the fence with the same character count.
```
plain code block
multiple lines
```
~~~
also a fenced block
using tildes
~~~Syntax Highlighting
Add a language identifier right after the opening fence for syntax highlighting (e.g. js, python). Most renderers use highlight.js or Prism. Common aliases: js, ts, py, rb, sh, json, html, css. If the language is unknown, omit it for plain monospace.
```javascript
const greet = (name) => {
console.log(`Hello, ${name}!`);
};
```
```python
def greet(name):
print(f"Hello, {name}!")
```
```bash
echo "Hello, $USER"
```Nested Code Fences
To display backticks inside a code block, use a different fence (tildes for backtick content, or more backticks than appear inside). Four backticks fence content containing triple backticks. The closing fence must match the opening length.
Use four backticks to wrap triple backticks:
````
```js
console.log("inside");
```
````
Or use tildes to wrap backtick content:
~~~
```js
code with backticks
```
~~~Code in Lists
Fenced code blocks inside list items must be indented to align with the list text (typically 3 spaces for - lists, 4 for 1. lists). Indented code blocks inside lists need 8 spaces (4 for the list + 4 for code). Getting alignment right is one of the trickier Markdown tasks.
1. Item with code:
```
code block indented to align
```
2. Next item with inline `code`.
- Or indent code 4 spaces beyond
the list marker (8 total).Blockquotes
Basic Blockquote
The > character starts a blockquote. You can prefix every line or just the first — most parsers join consecutive lines. Blockquotes render as indented, styled quotes (<blockquote>). Use them for quotations, callouts, and highlighting excerpts.
> This is a blockquote.
> It can span multiple lines.
> Or just prefix the first line
and continuation lines without >
will still be part of the quote.Multi-line Blockquote
Use blank > lines to separate paragraphs within a blockquote (otherwise they merge). The > on a blank line keeps the quote open. Without blank lines between paragraphs, the text flows as one paragraph. Always close with a normal line.
> First paragraph of quote.
>
> Second paragraph of quote.
>
> > Nested quote starts here.
> > Continues on next line.
End of quote.Nested Blockquotes
Multiple > characters create nested blockquotes (>> for two levels, >>> for three). Add spaces for readability. Deep nesting (3+ levels) becomes hard to read and style — prefer flattening. Each level adds indentation in HTML output.
> Outer quote
>
> > Inner nested quote
> > still nested
>
> Back to outer
> Outer
>> Deeper
>>> Deepest levelBlockquotes with Other Elements
Blockquotes can contain most Markdown elements: headings, lists, code, emphasis, even tables. Prefix each line with > (and a space) to keep them inside the quote. This makes blockquotes powerful for callouts, but complex content requires careful > alignment.