Introduction

Markdown is a lightweight markup language that allows you to write formatted text using a plain-text syntax.

It’s widely used for writing documentation, blog posts, and even creating web pages.

In this cheat sheet, I’ll cover the most commonly used Markdown syntax and their corresponding formatting options.

Headings

You can create headings by using one to six hash characters (#) at the beginning of the line. The number of hashes represents the heading level.

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

Emphasis

You can emphasise text using the following options:

  • Bold: Surround the text with double asterisks (**) or double underscores (__).
  • Italic: Surround the text with single asterisks (*) or single underscores (_).
  • Bold and Italic: Combine both using triple asterisks (***) or triple underscores (___).
**Bold**

__Bold__

*Italic*

_Italic_

***Bold and Italic***

___Bold and Italic___

Lists

Markdown supports both ordered and unordered lists.

  • Unordered List: Begin each item with a hyphen (-), plus sign (+), or asterisk (*).
  • Ordered List: Begin each item with a number followed by a period (1., 2., etc.).
- Item 1
- Item 2
- Item 3

1. Item 1
2. Item 2
3. Item 3

You can create links in Markdown using the following syntax:

  • Inline Links: [Link Text](URL)
  • Reference Links: [Link Text][Reference ID] and later [Reference ID]: URL
[Google](https://www.google.co.uk)

[Andrew Beaton][1]
[1]: https://andrewbeaton.net

Images

To include images in your Markdown document, use the following format:

![Alt Text](URL)

Code Blocks

You can display code blocks or inline code using backticks (`):

  • Inline Code: Surround the code with single backticks.

  • Code Block: Surround the code with triple backticks, optionally specifying the language for syntax highlighting.

console.log("Hello, Markdown!");
def greet():
    print("Hello, Markdown!")

Blockquotes

Blockquotes are used to display quoted text. You can create a blockquote by using a greater than symbol (>).

> This is a blockquote.

Horizontal Rule

To create a horizontal rule, use three or more hyphens (---), asterisks (***), or underscores (___).

---

Tables

Tables can be created using hyphens (-) and pipes (|) to define the columns and rows.

| Column 1 | Column 2 |
| -------- | -------- |
| Row 1    | Row 1    |
| Row 2    | Row 2    |

Escaping Characters

To display characters that have special meaning in Markdown, you can use a backslash (\) before the character to escape it.

\*This is not italic\*

Task Lists

You can create task lists using square brackets ([ ] for incomplete tasks and [x] for completed tasks).

- [ ] Task 1
- [x] Task 2
- [ ] Task 3

Strikethrough

To strike through text, use two tilde characters (~~).

~~This text is strikethrough.~~ 

Footnotes

Markdown supports footnotes, allowing you to add additional information or references at the bottom of the page.

Here is some text with a footnote[^1].

[^1]: This is the footnote content.

Superscript and Subscript

To create superscript and subscript text, use the caret (^) for superscript and tilde (~) for subscript.

This is a superscript: X^2^
This is a subscript: H~2~O

Abbreviations

Markdown allows you to define abbreviations, which can be useful for providing explanations or definitions.

The HTML stands for Hypertext Markup Language. [^HTML]

[^HTML]: Hypertext Markup Language

Raw HTML

Markdown supports the use of raw HTML code for more advanced formatting options. You can embed HTML elements directly within your Markdown document.

This is a <span style="color: red;">red</span> text.

Inline Math Equations

If you need to include mathematical equations, you can use LaTeX syntax within Markdown to render them.

The quadratic equation is \(ax^2 + bx + c = 0\).

Definition Lists

Markdown also supports definition lists for glossaries or terms with corresponding explanations.

Term 1
:   This is the definition of Term 1.

Term 2
:   This is the definition of Term 2.

Inline HTML

Markdown allows you to directly insert HTML code inline within your Markdown document. This can be useful for more complex formatting or embedding multimedia.

This is an <kbd>inline HTML</kbd> example.

Definition of Acronyms

Similar to abbreviations, Markdown supports the definition of acronyms using the same syntax.

The HTTP stands for Hypertext Transfer Protocol. [^HTTP]

[^HTTP]: Hypertext Transfer Protocol

Emoji

Markdown supports the use of emojis to add visual elements to your text. You can include emojis using emoji codes or Unicode characters. 😃

I am feeling 😃 today!

Automatic URL Linking

By default, Markdown automatically converts URLs into clickable links. You don’t need to use any specific syntax.

Visit my website at https://andrewbeaton.net

Escape Characters

If you want to display characters that have a special meaning in Markdown, you can escape them using a backslash (\).

\*This is not a bullet point\*

Summary

This cheat sheet covers the most commonly used Markdown syntax.

Markdown provides a simple and efficient way to format text without getting in the way of your writing.

Related Posts