- What is Markdown?
- Headings
-
Heading 1
- Heading 2
- Heading 3
- Paragraphs
- Line Breaks
- Emphasis
- Blockquotes
- Lists
- Code
- Horizontal Rules
- Links
- Basic Links
- Links with Titles
- Reference Links
- URLs
- Images
- Basic Images
- Images with Titles
- Reference Images
- Resizing Images
- Tables
- Basic Table
- Aligning Text in Columns
- Complex Tables
- Inline HTML
- Escaping Characters
- Extended Syntax
- Task Lists
- Footnotes
- Definition Lists
- Strikethrough
- Tables of Contents
- Table of Contents
Markdown is a lightweight markup language used to format text. It's easy to learn and use, making it a popular choice for writing documentation, blogs, and even books. This comprehensive guide will cover everything you need to know about Markdown, from basic syntax to advanced techniques. Whether you're a beginner or an experienced user, this cheatsheet will serve as a valuable resource.
What is Markdown?
Markdown was created by John Gruber in 2004 as a way to write content in plain text that's easy to read and easy to convert to HTML. The syntax is simple and intuitive, allowing writers to focus on their content rather than worrying about formatting.
The primary goal of Markdown is to be as readable as possible in its raw form. This means that even without rendering, a Markdown document should be easy to read and understand.
Headings
Headings are created using the #
symbol. The number of #
symbols indicates the level of the heading.
# Heading 1
## Heading 2
## Heading 3
### Heading 4
#### Heading 5
#### Heading 6
Rendered as:
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Paragraphs
A paragraph is simply one or more lines of text followed by one or more blank lines.
This is a paragraph.
This is another paragraph.
Rendered as:
This is a paragraph.
This is another paragraph.
Line Breaks
To create a line break (a new line within the same paragraph), end a line with two or more spaces, or use the <br>
HTML tag.
This is the first line.
This is the second line.
Rendered as:
This is the first line.
This is the second line.
Emphasis
Emphasis is created using asterisks *
or underscores _
.
-
Bold: Wrap the text with
**
or__
. -
Italic: Wrap the text with
*
or_
. -
Bold and Italic: Wrap the text with
***
or___
.
**Bold Text**
*Italic Text*
***Bold and Italic Text***
Rendered as:
Bold Text
Italic Text
Bold and Italic Text
Blockquotes
Blockquotes are used to denote quoted text and are created using the >
symbol.
> This is a blockquote.
>
> It can span multiple lines.
Rendered as:
This is a blockquote.
It can span multiple lines.
Lists
Markdown supports both ordered (numbered) and unordered (bulleted) lists.
Unordered Lists
Unordered lists are created using *
, +
, or -
.
- Item 1
- Item 2
- Subitem 1
- Subitem 2
* Item 3
+ Item 4
Rendered as:
- Item 1
- Item 2
- Subitem 1
- Subitem 2
- Item 3
- Item 4
Ordered Lists
Ordered lists are created by starting each item with a number followed by a period.
1. First item
2. Second item
1. Subitem 1
2. Subitem 2
3. Third item
Rendered as:
- First item
- Second item
- Subitem 1
- Subitem 2
- Third item
Code
Inline Code
Inline code is created by wrapping text with backticks `
.
Here is some `inline code`.
Rendered as:
Here is some inline code
.
Code Blocks
Code blocks are created by indenting lines with four spaces or one tab, or by wrapping the code with three backticks ```
.
``` def hello_world(): print("Hello, World!") ```
Rendered as:
def hello_world():
print("Hello, World!")
Horizontal Rules
Horizontal rules (or lines) are created by using three or more asterisks ***
, dashes ---
, or underscores ___
on a line by themselves.
---
***
___
Rendered as:
Links
Links can be created in Markdown in several ways, each serving different purposes.
Basic Links
The basic syntax for a link is [Link Text](URL)
.
[Accreditly](https://www.accreditly.io)
Rendered as:
Links with Titles
You can also add a title to your link, which will appear as a tooltip when you hover over the link.
[Accreditly](https://www.accreditly.io "Development Certifications")
Rendered as:
Reference Links
Reference links allow you to define your links separately from the text, which can be useful for keeping your Markdown files clean and organized.
This is a [reference link][accreditly].
[accreditly]: https://www.accreditly.io "Accreditly Site"
Rendered as:
This is a reference link.
URLs
You can also include URLs directly in your Markdown without link text.
https://www.accreditly.io
Rendered as:
https://www.accreditly.io
Images
Images in Markdown are similar to links, but they start with an exclamation mark !
.
Basic Images
![Alt Text](https://accreditly.io/storage/blogs/358/markdown-cheatsheet-600.webp)
Rendered as:
Images with Titles
Just like links, images can have titles.
![Alt Text](https://accreditly.io/storage/blogs/358/markdown-cheatsheet-600.webp "Image Title")
Rendered as:
Reference Images
Similar to reference links, you can use reference-style syntax for images.
![Alt Text][image1]
[image1]: https://accreditly.io/storage/blogs/358/markdown-cheatsheet-600.webp "Image Title"
Rendered as:
Resizing Images
Markdown doesn’t support image resizing natively, but you can use HTML for this purpose.
<img src="https://accreditly.io/storage/blogs/358/markdown-cheatsheet-600.webp" alt="Alt Text" width="200" height="200">
Rendered as:
Tables
Tables in Markdown are created using pipes |
and hyphens -
.
Basic Table
| Header 1 | Header 2 | Header 3 |
|----------|----------|----------|
| Row 1 | Data | Data |
| Row 2 | Data | Data |
Rendered as:
Header 1 | Header 2 | Header 3 |
---|---|---|
Row 1 | Data | Data |
Row 2 | Data | Data |
Aligning Text in Columns
You can align text in columns by using colons :
.
-
Left-aligned:
:---
-
Center-aligned:
:---:
-
Right-aligned:
---:
| Left Align | Center Align | Right Align |
|:-----------|:------------:|------------:|
| Row 1 | Data | Data |
| Row 2 | Data | Data |
Rendered as:
Left Align | Center Align | Right Align |
---|---|---|
Row 1 | Data | Data |
Row 2 | Data | Data |
Complex Tables
Tables can be complex, including headers spanning multiple rows and columns. However, for more complex tables, it's often better to use HTML.
<table>
<tr>
<th rowspan="2">Header 1</th>
<th colspan="2">Header 2</th>
</tr>
<tr>
<td>Subheader 1</td>
<td>Subheader 2</td>
</tr>
<tr>
<td>Row 1</td>
<td>Data 1</td>
<td>Data 2</td>
</tr>
<tr>
<td>Row 2</td>
<td>Data 3</td>
<td>Data 4</td>
</tr>
</table>
Rendered as:
Header 1 | Header 2 | |
---|---|---|
Subheader 1 | Subheader 2 | |
Row 1 | Data 1 | Data 2 |
Row 2 | Data 3 | Data 4 |
Inline HTML
Markdown supports the use of inline HTML, allowing you to add features or styling that are not
possible with Markdown alone.
<div style="text-align: center;">
<p>This is centered text.</p>
</div>
Rendered as:
This is centered text.
Escaping Characters
If you need to use a Markdown character literally (e.g., asterisks, underscores), you can escape it with a backslash \
.
\*This text is not italicized\*
Rendered as:
*This text is not italicized*
Extended Syntax
In addition to the standard Markdown features, some implementations and extensions provide additional functionality.
Task Lists
Task lists are useful for creating to-do lists or checklists. They are created by using - [ ]
for unchecked items and - [x]
for checked items.
- [x] Task 1
- [ ] Task 2
- [ ] Task 3
Rendered as:
- [x] Task 1
- [ ] Task 2
- [ ] Task 3
Footnotes
Some Markdown processors support footnotes, which allow you to create references within your text.
This is a footnote reference[^1].
[^1]: This is the footnote.
Rendered as:
This is a footnote reference[^1].
[^1]: This is the footnote.
Definition Lists
Definition lists are used to create a list of terms and their definitions.
Term 1
: Definition 1
Term 2
: Definition 2
Rendered as:
Term 1
: Definition 1
Term 2
: Definition 2
Strikethrough
Strikethrough text is created by wrapping text in ~~
.
~~This text is struck through~~
Rendered as:
~~This text is struck through~~
Tables of Contents
While not a native feature of Markdown, many Markdown processors can generate tables of contents based on the headings in your document. This is especially useful for longer documents.
# Table of Contents
- [Introduction](#introduction)
- [Basic Syntax](#basic-syntax)
- [Links](#links)
- [Images](#images)
Rendered as:
Table of Contents
Emojis
You can add emojis in Markdown using their shortcode or by using Unicode characters.
I :heart: Markdown! :smile:
Rendered as:
I ❤️ Markdown! 😄
Editors
There are many Markdown editors available, both as desktop applications and web-based tools.
- Typora: A popular, minimalistic Markdown editor with real-time preview.
- Visual Studio Code: A powerful code editor with Markdown support and extensions.
- Mark Text: An open-source Markdown editor with a focus on simplicity and readability.
- Obsidian: A knowledge management tool with Markdown support.
Tools
Several online tools can convert Markdown to other formats, validate your Markdown, or provide additional functionality.
- Markdownlint: A tool to check Markdown for style issues.
- Dillinger: An online Markdown editor that can export to PDF, HTML, and other formats.
- StackEdit: A full-featured online Markdown editor that integrates with cloud storage.
Converting Markdown to Other Formats
Markdown can be converted to various formats, including HTML, PDF, and Word documents. This is often done using tools like Pandoc or Markdown processors integrated into other software.
pandoc input.md -o output.pdf
This command converts a Markdown file to PDF using Pandoc.
Mastering Markdown
Markdown is a versatile and powerful tool for writers, developers, and content creators. Its simplicity and readability make it an ideal choice for a wide range of applications, from documentation to blogging. With the comprehensive knowledge you've gained from this cheatsheet, you can now confidently create and format content using Markdown.
Whether you're writing a simple README file or creating complex documents, Markdown provides a clean, efficient way to format text without the overhead of more complex languages like HTML. As you continue to use Markdown, you'll find it to be an invaluable tool in your workflow.
Explore Further
For more detailed information, consider these resources:
By mastering Markdown, you empower yourself to create beautifully formatted content with minimal effort. Whether you're new to Markdown or a seasoned pro, this guide will serve as a handy reference.