Markdown

Essential Markdown syntax for formatting text, creating links, tables, and more.

languages
markdowndocumentationtextformattingreadme

Headings

# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6

Alternative Heading 1
=====================

Alternative Heading 2
---------------------

Text Formatting

**Bold text**
__Also bold__

*Italic text*
_Also italic_

***Bold and italic***
___Also bold and italic___

~~Strikethrough~~

`Inline code`

> Blockquote
> Multiple lines
>
> With paragraph break

> Nested blockquote
>> Second level
>>> Third level

Lists

# Unordered lists
- Item 1
- Item 2
  - Nested item
  - Another nested
- Item 3

* Also works
* With asterisks

+ Or plus signs
+ Like this

# Ordered lists
1. First item
2. Second item
   1. Nested numbered
   2. Another nested
3. Third item

# Mixed lists
1. First item
   - Nested bullet
   - Another bullet
2. Second item

# Task lists (checkboxes)
- [ ] Unchecked task
- [x] Completed task
- [ ] Another task
# Inline links
[Link text](https://example.com)
[Link with title](https://example.com "Title on hover")

# Reference links
[Link text][reference]
[reference]: https://example.com

# Automatic links
<https://example.com>
<email@example.com>

# Relative links
[Go to docs](./docs/README.md)
[Parent directory](../other-file.md)

# Section links (anchors)
[Go to section](#section-name)
[Link to heading](#headings)

Images

# Inline image
![Alt text](image.jpg)
![Alt text](image.jpg "Image title")

# Reference image
![Alt text][img-ref]
[img-ref]: image.jpg "Optional title"

# Image with link
[![Alt text](image.jpg)](https://example.com)

# HTML for sizing (when supported)
<img src="image.jpg" alt="Alt text" width="200">

Code

# Inline code
Use `const` instead of `var`.

# Code block (indented)
    function hello() {
      console.log("Hello");
    }

# Fenced code block
```
Plain code block
No syntax highlighting
```

# Fenced with language
```javascript
function hello() {
  console.log("Hello");
}
```

```python
def hello():
    print("Hello")
```

```bash
echo "Hello World"
```

Tables

# Basic table
| Header 1 | Header 2 | Header 3 |
|----------|----------|----------|
| Cell 1   | Cell 2   | Cell 3   |
| Cell 4   | Cell 5   | Cell 6   |

# Alignment
| Left     | Center   | Right    |
|:---------|:--------:|---------:|
| Left     | Center   | Right    |
| aligned  | aligned  | aligned  |

# Compact syntax
Header 1|Header 2|Header 3
--------|--------|--------
Cell 1|Cell 2|Cell 3

Horizontal Rules

---

***

___

- - -

* * *

Line Breaks

# Two spaces at end of line  
Creates a line break

# Or use HTML
Line one<br>Line two

# Blank line creates new paragraph
First paragraph.

Second paragraph.

Escaping Characters

# Escape with backslash
\*Not italic\*
\# Not a heading
\[Not a link\]
\`Not code\`

# Characters that can be escaped
\   backslash
`   backtick
*   asterisk
_   underscore
{}  curly braces
[]  square brackets
()  parentheses
#   hash mark
+   plus sign
-   minus sign
.   dot
!   exclamation mark
|   pipe

HTML in Markdown

# Inline HTML
<strong>Bold</strong>
<em>Italic</em>
<mark>Highlighted</mark>
<sub>subscript</sub>
<sup>superscript</sup>

# Block HTML
<div align="center">
  Centered content
</div>

<details>
<summary>Click to expand</summary>

Hidden content here.
Can include **markdown**.

</details>

# Keyboard keys
<kbd>Ctrl</kbd> + <kbd>C</kbd>

# Abbreviations
<abbr title="HyperText Markup Language">HTML</abbr>

GitHub Flavored Markdown

# Autolinked references
Issue: #123
PR: #456
Commit: a1b2c3d
User: @username

# Footnotes
Here's a sentence with a footnote[^1].

[^1]: This is the footnote content.

# Alerts/Admonitions (GitHub)
> [!NOTE]
> Useful information.

> [!TIP]
> Helpful advice.

> [!IMPORTANT]
> Key information.

> [!WARNING]
> Urgent warning.

> [!CAUTION]
> Negative consequences.

# Emoji
:smile: :rocket: :+1:
Unicode also works: 😀 🚀 👍

# Syntax highlighting diff
```diff
- Removed line
+ Added line
  Unchanged line

## Definition Lists

```markdown
# Some parsers support definition lists
Term 1
: Definition 1

Term 2
: Definition 2a
: Definition 2b

Math (LaTeX)

# Inline math
The equation $E = mc^2$ is famous.

# Block math
$$
\frac{n!}{k!(n-k)!} = \binom{n}{k}
$$

# Sum notation
$$
\sum_{i=1}^{n} x_i
$$

Comments

<!-- This is a comment -->
<!-- 
Multi-line
comment 
-->

[//]: # (This is also a comment)
[//]: # "Alternative comment syntax"

Best Practices

# Spacing
- Blank line before/after headings
- Blank line before/after code blocks
- Blank line before/after lists

# Consistency
- Use same style for bold (* or _)
- Use same list marker (-, *, +)
- Use consistent heading style

# Accessibility
- Always add alt text to images
- Use descriptive link text
- Structure with proper headings

# File naming
- Use lowercase
- Use hyphens for spaces
- Include .md extension