Complete Markdown Syntax Cheatsheet with Examples | Sagar Nikam Notes
Post

Complete Markdown Syntax Cheatsheet with Examples

Complete markdown syntax guide with examples covering text formatting, headers, lists, code blocks, tables, links, images, footnotes, and advanced features for developers and writers.

Complete Markdown Syntax Cheatsheet with Examples

Text Formatting

Emphasis

Bold text

1
**Bold text** or __Bold text__

Italic text

1
*Italic text* or _Italic text_

Bold and italic

1
***Bold and italic*** or **_Bold and italic_**

Strikethrough

1
~~Strikethrough~~

Superscript and Subscript

E=mc2

1
E=mc<sup>2</sup>

H2O

1
H<sub>2</sub>O

Escape Characters

Use backslash to escape special characters: *literal asterisks*

1
\*literal asterisks\*

Headers

H1 Header

H2 Header

H3 Header

H4 Header

H5 Header
H6 Header
1
2
3
4
5
6
# H1 Header
## H2 Header
### H3 Header
#### H4 Header
##### H5 Header
###### H6 Header

Setext Style

Header 1

Header 2

1
2
3
4
5
Header 1
========

Header 2
--------

Lists

Unordered Lists

  • Item 1
  • Item 2
    • Nested item
    • Another nested item
  • Item 3
1
2
3
4
5
* Item 1
* Item 2
  * Nested item
  * Another nested item
* Item 3

Ordered Lists

  1. First item
  2. Second item
    1. Nested item
    2. Another nested item
  3. Third item
1
2
3
4
5
1. First item
2. Second item
   1. Nested item
   2. Another nested item
3. Third item

Task Lists

  • Completed task
  • Incomplete task
  • Another completed task
1
2
3
- [x] Completed task
- [ ] Incomplete task
- [x] Another completed task

This is a Google link.

1
[Google](https://www.google.com "Google Homepage")

This is a reference link and another reference link.

1
2
3
4
5
[reference link][1]
[reference link][google]

[1]: https://www.google.com "Google"
[google]: https://www.google.com

https://www.google.com

1
https://www.google.com

Images

Inline Images

Alt text

1
![Alt text](https://via.placeholder.com/150 "Image title")

Reference Images

Google Logo

1
2
3
![Google Logo][logo]

[logo]: https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png

Code

Inline Code

Use backticks for inline code.

1
Use `backticks` for inline code.

Code Blocks

1
Plain code block
1
2
3
```
Plain code block
```

Syntax Highlighting

1
2
3
function hello() {
    console.log("Hello World!");
}
1
2
3
4
5
```javascript
function hello() {
    console.log("Hello World!");
}
```

Indented Code Blocks

1
2
This is an indented code block
using 4 spaces or 1 tab
1
2
    This is an indented code block
    using 4 spaces or 1 tab

Line Numbers in Code Blocks

```javascript {linenos=true} function hello() { console.log(β€œHello World!”); return true; }

1

```javascript {linenos=true} function hello() { console.log(β€œHello World!”); return true; }

1

Tables

Left AlignedCenter AlignedRight Aligned
LeftCenterRight
TextTextText
1
2
3
4
| Left Aligned | Center Aligned | Right Aligned |
|:-------------|:--------------:|--------------:|
| Left         | Center         | Right         |
| Text         | Text           | Text          |

Simple Table

Column 1Column 2Column 3
Data 1Data 2Data 3
Data 4Data 5Data 6
1
2
3
4
Column 1 | Column 2 | Column 3
---------|----------|----------
Data 1   | Data 2   | Data 3
Data 4   | Data 5   | Data 6

Blockquotes

This is a blockquote.

It can span multiple lines.

Nested blockquotes are also possible.

1
2
3
4
5
> This is a blockquote.
> 
> It can span multiple lines.
> 
> > Nested blockquotes are also possible.

Horizontal Rules

Three or more dashes, asterisks, or underscores:




1
2
3
---
***
___

Line Breaks

End a line with two or more spaces for a line break.

First line
Second line

1
2
First line  
Second line

HTML Elements

Definition Lists

Term 1
Definition 1
Term 2
Definition 2
1
2
3
4
5
6
<dl>
  <dt>Term 1</dt>
  <dd>Definition 1</dd>
  <dt>Term 2</dt>
  <dd>Definition 2</dd>
</dl>

Preformatted Text

Preformatted text
preserves   spaces
and line breaks
1
2
3
4
5
<pre>
Preformatted text
preserves   spaces
and line breaks
</pre>

Media

YouTube Videos (HTML)

Video Thumbnail

1
2
3
<a href="https://www.youtube.com/watch?v=BZhWUE1A198" target="_blank">
  <img src="https://img.youtube.com/vi/BZhWUE1A198/0.jpg" alt="Video Thumbnail" width="240" height="180">
</a>

YouTube Videos (Markdown)

Video Thumbnail

1
[![Video Thumbnail](https://img.youtube.com/vi/BZhWUE1A198/0.jpg)](https://www.youtube.com/watch?v=BZhWUE1A198)

Special Features

Emoji

πŸ˜„ ❀️ πŸ‘ πŸ™ (Unicode) or :smile: :heart: :thumbsup: :octocat: (shortcodes)

1
2
πŸ˜„ ❀️ πŸ‘ πŸ™ (Unicode)
:smile: :heart: :thumbsup: :octocat: (shortcodes - requires jemoji plugin)

Emoji Cheatsheet

Highlighting

Highlighted text

1
<mark>Highlighted text</mark>

Keyboard Keys

Press Ctrl + C to copy.

1
Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy.

Math Expressions

Inline Math

This is inline math: $E = mc^2$

1
$E = mc^2$

Block Math

\[\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}\]
1
2
3
$$
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$

Note: Requires MathJax or KaTeX support


Footnotes

This text has a footnote1.

1
2
3
This text has a footnote[^1].

[^1]: This is the footnote content.

Comments

1
<!-- This is a comment that won't be visible -->

Collapsible Sections

Click to expand This content is hidden by default and can be expanded by clicking the summary. - Item 1 - Item 2 - Item 3
1
2
3
4
5
6
<details>
<summary>Click to expand</summary>

This content is hidden by default.

</details>

Custom ID Headers

Link to custom header

1
2
### Custom ID Headers {#custom-header}
[Link to custom header](#custom-header)

Best Practices

  1. Use consistent formatting throughout your document
  2. Add blank lines around headers and sections for readability
  3. Use descriptive alt text for images
  4. Include titles for links when helpful
  5. Test your markdown in your target renderer
  6. Use reference links for repeated URLs
  7. Indent nested lists properly with 2-4 spaces
  8. Use semantic headers (H1 for title, H2 for main sections)
  9. Keep line length reasonable (80-120 characters)
  10. Preview before publishing to catch formatting issues

Conclusion

This comprehensive markdown cheatsheet covers all essential syntax from basic text formatting to advanced features like math expressions and collapsible sections. Bookmark this reference for quick lookup while writing documentation, README files, or blog posts. Remember to test your markdown in your target environment since different renderers may have slight variations in support.

  1. This is the footnote content.Β ↩︎

This post is licensed under CC BY 4.0 by the author.