Markdown Cheatsheet: A Comprehensive Guide
Markdown is a lightweight markup language created to format text using a plain-text editor. It’s favored by writers, developers, and content creators due to its simplicity and versatility. Understanding Markdown is crucial for anyone working with text on the web, as it’s commonly used in documentation, blogs, and online platforms like GitHub.
This guide provides a comprehensive Markdown cheatsheet, helping you quickly learn or reference essential Markdown syntax.
1. Basic Text Formatting
Bold Text
To make text bold, enclose it with double asterisks **
or double underscores __
.
Example: **This is bold**
or __This is also bold__
Result: This is bold or This is also bold
Italic Text
Italicize text by wrapping it in single asterisks *
or single underscores _
.
Example: *This is italic*
or _This is also italic_
Result: This is italic or This is also italic
Strikethrough
To strike through text, use double tildes ~~
.
Example: ~~This is strikethrough~~
Result: This is strikethrough
Inline Code
Use backticks `
to display inline code or commands.
Example: `code example`
Result: code example
2. Headers
Markdown allows you to create headers of different sizes using the hash #
symbol.
- H1 Header:
# Header 1
- H2 Header:
## Header 2
- H3 Header:
### Header 3
- H4 Header:
#### Header 4
- H5 Header:
##### Header 5
- H6 Header:
###### Header 6
Example:
shell# This is H1 ## This is H2 ### This is H3
Result:
This is H1
This is H2
This is H3
3. Lists
Unordered Lists
Create unordered lists using asterisks *
, plus +
, or hyphens -
.
Example:
diff- Item 1 - Item 2 - Item 3
Result:
- Item 1
- Item 2
- Item 3
Ordered Lists
For ordered lists, simply use numbers followed by a period .
.
Example:
markdown1. First item 2. Second item 3. Third item
Result:
- First item
- Second item
- Third item
4. Links and Images
Links
Create hyperlinks using square brackets []
for the text and parentheses ()
for the URL.
Example: [Google](https://www.google.com)
Result: Google
Images
To add an image, use an exclamation mark !
followed by alt text in square brackets []
and the image URL in parentheses ()
.
Example: ![Alt text](https://example.com/image.jpg)
Result:
5. Blockquotes
Blockquotes are used to highlight a section of text. To create one, use the greater-than symbol >
before the text.
Example:
css> This is a blockquote.
Result:
This is a blockquote.
For nested blockquotes, add additional >
symbols.
Example:
csharp> This is the first level of quoting. >> This is nested.
Result:
This is the first level of quoting.
This is nested.
6. Code Blocks
For code that spans multiple lines, use triple backticks or indent each line with four spaces.
Example:
def hello_world(): print(“Hello, world!”)
Result:
scssdef hello_world(): print("Hello, world!")
7. Horizontal Rules
To create a horizontal rule, use three or more hyphens ---
, asterisks ***
, or underscores ___
.
Example:
yaml---
Result:
8. Tables
Markdown allows you to create simple tables using pipes |
and hyphens -
.
Example:
css| Header 1 | Header 2 | Header 3 | |----------|----------|----------| | Row 1 | Data 1 | Data 1 | | Row 2 | Data 2 | Data 2 |
Result:
Header 1 | Header 2 | Header 3 |
---|---|---|
Row 1 | Data 1 | Data 1 |
Row 2 | Data 2 | Data 2 |
To align text, add colons :
within the hyphens.
:---
aligns left.:---:
centers.---:
aligns right.
Example:
ruby| Left-Aligned | Center-Aligned | Right-Aligned | |:------------ |:--------------:| -------------:| | Data | Data | Data |
Result:
Left-Aligned | Center-Aligned | Right-Aligned |
---|---|---|
Data | Data | Data |
9. Escaping Characters
If you need to display Markdown symbols as plain text, escape them with a backslash .
Example: *This will not be italicized*
Result: *This will not be italicized*
10. Task Lists
Markdown supports task lists, which are particularly useful for tracking to-dos.
Use square brackets [ ]
for unchecked tasks and [x]
for checked ones.
Example:
css- [x] Completed task - [ ] Incomplete task
Result:
- Completed task
- Incomplete task
11. Emoji
You can include emojis in Markdown using colons :
followed by the emoji name.
Example: :smile:
Result: 😄
GitHub and other platforms provide extensive lists of supported emojis.
12. Footnotes
Markdown allows for footnotes by adding square brackets []
with a caret ^
and an identifier inside. The footnote content is added at the bottom, starting with the same identifier inside square brackets.
Example:
csharpThis is an example with a footnote.[^1] [^1]: This is the footnote content.
Result:
This is an example with a footnote.1
13. Custom HTML
Markdown supports embedding HTML for additional customization. For instance, you can create a collapsible section or add custom styling.
Example:
html<div style="color:blue;">This is blue text.</div>
Result:<div style=”color:blue;”>This is blue text.</div>
This feature is useful when Markdown’s built-in features don’t meet your needs.
Conclusion
Markdown is an incredibly versatile and easy-to-learn language for formatting text. This cheatsheet covers the essentials, allowing you to create well-structured and visually appealing documents. Whether you’re writing documentation, creating a blog post, or formatting a README file, Markdown makes the process straightforward and efficient.
Remember, practice is key to mastering Markdown. Experiment with different elements and incorporate them into your daily workflow. Over time, you’ll find yourself navigating Markdown with ease, creating clean and professional-looking documents with minimal effort.
Now that you have this cheatsheet, you’re well-equipped to use Markdown effectively in any writing task. Happy writing!
Thank you for reading the article! If you found the information useful, you can donate using the buttons below:
Donate ☕️ with PayPalDonate 💳 with Revolut