Markdown Basics
Master the fundamental syntax and core concepts of Markdown formatting
Reading Time
20 minutes
Difficulty
Beginner Friendly
Prerequisites
None
Table of Contents π
Introduction to Markdown π
Markdown is a lightweight markup language created by John Gruber in 2004. It's designed to be easy to read and write, while being convertible to structurally valid HTML. With its simple syntax and wide adoption, Markdown has become the go-to format for documentation, README files, and content creation.
Why Learn Markdown? π€
- β¨Simple and Intuitive Syntax
Easy to learn and remember, with minimal special characters
- π±Platform Independence
Write once, use anywhere - from websites to documentation
- πWide Platform Support
Used on GitHub, Discord, Notion, and countless other platforms
- πPerfect for Documentation
Industry standard for technical documentation and README files
- βοΈContent Creation
Ideal for blog posts, technical writing, and note-taking
Common Use Cases π―
Documentation
- β’ Project README files
- β’ API documentation
- β’ User guides
Content Creation
- β’ Blog posts
- β’ Technical articles
- β’ Tutorial writing
Quick Tip
Throughout this tutorial, you'll see examples with both the Markdown syntax and its rendered output. We encourage you to practice by typing out these examples in your own Markdown editor. The best way to learn is by doing!
Popular Markdown Tools π οΈ
Online Editors
- β’ StackEdit
- β’ Dillinger
- β’ HackMD
Desktop Apps
- β’ Visual Studio Code
- β’ Typora
- β’ Obsidian
Headers and Document Structure π
Headers in Markdown create a clear document hierarchy and structure. They're essential for organizing content and making it easy to navigate. Markdown supports six levels of headers, each denoted by a different number of hash symbols (#).
Header Syntax Examples
# Heading Level 1
Heading Level 1
## Heading Level 2
Heading Level 2
### Heading Level 3
Heading Level 3
Alternative Header Syntax
Heading Level 1
===============
Heading Level 1
Heading Level 2
---------------
Heading Level 2
Header Best Practices π
- π―Single H1 Per Document
Use only one level 1 header (#) per document as the main title
- πConcise and Descriptive
Keep headers clear and to the point, accurately describing the content
- πProper Hierarchy
Maintain logical header levels (don't skip from H2 to H4)
- π¨Consistent Style
Use consistent capitalization and formatting across headers
Common Mistakes to Avoid
- β
##No space after hashes
Always include a space after the hash symbols
- β
Multiple H1 Headers
Avoid using multiple H1 headers in a single document
- β
## h2 ### h3 ##### h5
Don't skip header levels in your hierarchy
Paragraphs and Line Breaks βοΈ
Paragraphs are the fundamental building blocks of Markdown documents. Understanding how to properly format paragraphs and create line breaks is essential for creating well-structured content.
Basic Paragraphs
This is the first paragraph.
This is the second paragraph.
This is the third paragraph with
no line break in between.
This is the first paragraph.
This is the second paragraph.
This is the third paragraph with no line break in between.
Key Points About Paragraphs
- β’
Paragraphs are separated by blank lines
- β’
Single line breaks within paragraphs are ignored
- β’
Leading spaces/tabs are typically ignored
Line Breaks
There are three ways to create line breaks in Markdown:
1. Two Spaces Method
First lineΒ·Β·β΅ Second line
(Β· represents a space)
First line
Second line
2. Backslash Method
First line\ Second line
First line
Second line
3. HTML Break Tag
First line<br> Second line
First line
Second line
Common Mistakes
- β
Single Line Break Without Marking
A single line break in your Markdown file won't create a line break in the output unless properly marked
- β
Missing Blank Line Between Paragraphs
Paragraphs need a blank line between them to be rendered separately
- β
Multiple Blank Lines
Multiple blank lines are treated the same as a single blank line
Best Practices
- β¨Consistency is Key
Choose one line break method and stick to it throughout your document
- πUse Blank Lines Deliberately
Separate paragraphs with a single blank line for clarity
- π―Keep Lines Readable
Aim for lines around 80 characters for optimal readability
Text Emphasis and Formatting π¨
Text formatting in Markdown allows you to emphasize your content in various ways. Whether you need to highlight important points, mark technical terms, or add emphasis to your writing, Markdown provides several options for text styling.
Basic Text Formatting
Italic Text
*This text is italic using asterisks*
_This text is italic using underscores_
This text is italic using asterisks
This text is italic using underscores
- Emphasis within sentences
- Book titles or publication names
- Technical terms or foreign words
- Variable names in technical writing
Bold Text
**This text is bold using asterisks**
__This text is bold using underscores__
This text is bold using asterisks
This text is bold using underscores
- Important points or warnings
- Key terms in documentation
- UI element names
- Section headers within paragraphs
Combined Formatting
***Bold and italic text***
___Also bold and italic___
**Bold text with *italic* inside**
*Italic text with **bold** inside*
Bold and italic text
Also bold and italic
Bold text with italic inside
Italic text with bold inside
Advanced Text Formatting
Strikethrough
~~Strikethrough text~~
Strikethrough text
Highlighting
<mark>Highlighted text</mark>
Highlighted text
Subscript and Superscript
H<sub>2</sub>O
X<sup>2</sup>
H2O
X2
Real-World Examples
Technical Documentation:
The **`fontSize`** property accepts values in *px*, *em*, or *rem* units.
The `fontSize` property accepts values in px, em, or rem units.
Content Writing:
I 'really' can't emphasize this "important point" enough!
I really can't emphasize this important point enough!
Best Practices
- π―Choose One Style
Stick to either asterisks (*) or underscores (_) consistently throughout your document
- πMind Your Spaces
Avoid spaces between formatting marks and text: use **bold** not ** bold **
- π¨Use Sparingly
Too much emphasis can make text harder to read. Use formatting thoughtfully
- πSemantic Usage
Use formatting to convey meaning, not just for visual effect
Common Mistakes
- β
* Incorrect spacing *
Don't add spaces between markers and text
- β
**_Mixing styles_**
Stick to one style for consistency
- β
***Nested formatting without spaces***
Use spaces when nesting different formatting styles
Lists (Ordered and Unordered) π
Lists in Markdown help organize information in a clear, scannable format. Whether you need numbered steps, bullet points, or nested items, Markdown's list syntax provides flexible options for structuring your content.
Unordered Lists
Unordered lists can be created using asterisks (*), plus signs (+), or hyphens (-) as bullet points.
* First item
* Second item
* Third item
- Another item
- Yet another item
+ Also works
+ With plus signs
- First item
- Second item
- Third item
- Another item
- Yet another item
- Also works
- With plus signs
Nested Lists
* Main item 1
* Nested item 1.1
* Nested item 1.2
* Even deeper item
* Another deep item
* Main item 2
* Nested item 2.1
* Nested item 2.2
- Main item 1
- Nested item 1.1
- Nested item 1.2
- Even deeper item
- Another deep item
- Main item 2
- Nested item 2.1
- Nested item 2.2
Ordered Lists
1. First step
2. Second step
3. Third step
1. Numbers don't matter
1. Markdown will count
1. For you automatically
- First step
- Second step
- Third step
- Numbers don't matter
- Markdown will count
- For you automatically
Nested Ordered Lists
1. First level
1. Second level
2. Another second level
1. Third level
2. Another third level
2. Back to first level
1. Second level again
- First level
- Second level
- Another second level
- Third level
- Another third level
- Back to first level
- Second level again
Mixed Lists
1. First ordered item
2. Second ordered item
* Unordered sub-item
* Another sub-item
3. Third ordered item
1. Ordered sub-item
2. Another ordered sub-item
* Mixed nesting
- First ordered item
- Second ordered item
- Unordered sub-item
- Another sub-item
- Third ordered item
- Ordered sub-item
- Another ordered sub-item
- Mixed nesting
Task Lists
- [x] Completed task
- [ ] Uncompleted task
- [x] Another completed task
- [ ] Nested task
- [x] Completed nested task
- Completed task
- Uncompleted task
- Another completed task
- Nested task
- Completed nested task
Best Practices
- π―Consistent Markers
Use the same marker type (* or - or +) throughout your document
- πProper Indentation
Use 2 or 4 spaces for each level of nesting
- βοΈLine Spacing
Add blank lines before and after lists for better readability
- πList Continuity
Keep list items of the same type together
Common Mistakes
- β
Inconsistent spacing
Keep indentation consistent for all nested items
- β
Missing line breaks
Separate lists from other content with blank lines
- β
Mixing marker types
Don't mix different bullet point styles in the same list
Links and References π
Links are essential for connecting your content to other resources. Markdown provides several ways to create links, from simple inline links to more maintainable reference-style links.
Inline Links
Basic Link Syntax
[Link text](URL)
[Visit our website](https://example.com)
[Contact support](mailto:support@example.com)
Links with Titles
[Link text](URL "Title text")
[Documentation](https://docs.example.com "View our docs")
Hover over the link to see the title
Reference-style Links
Reference-style links use a two-part syntax, making content more readable and maintainable.
[React][1] is a popular framework.
[Vue][2] is another great option.
[Angular][3] has strong typing support.
[1]: https://reactjs.org
[2]: https://vuejs.org "Vue.js"
[3]: https://angular.io 'Angular'
Collapsed Reference Links
[GitHub][] is a development platform.
[VS Code][] is a popular editor.
[github]: https://github.com
[vs code]: https://code.visualstudio.com
Special Link Types
Advanced Features
Handling Special Cases
[Link with spaces](path%20with%20spaces.html)
[Link with (parentheses)](<path(with)parentheses>)
URLs with spaces should be encoded using %20
URLs with special characters can be wrapped in <angle brackets>
Best Practices
- π―Descriptive Text
Use meaningful link text instead of "click here" or "read more"
- πReference Style
Use reference-style links for URLs that appear multiple times
- πProtocol Inclusion
Always include http:// or https:// in URLs
- πTitle Attributes
Add titles to provide additional context when helpful
Common Mistakes
- β
[Link text] (URL)
Don't put spaces between brackets and parentheses
- β
[Click here](URL)
Avoid non-descriptive link text
- β
[Link](example.com)
Don't forget the protocol (http:// or https://)
External Link Tips
When linking to external sites, consider:
- β’ Indicating when links open in new windows/tabs
- β’ Verifying that links are still active
- β’ Using HTTPS URLs when available
- β’ Adding relevant title attributes for context
Images and Media πΌοΈ
Images in Markdown follow a syntax similar to links, with an added exclamation mark (!) at the beginning. This section covers everything from basic image insertion to advanced techniques and best practices.
Basic Image Syntax


Basic image with alt text and title
The syntax consists of:
- ! - Indicates an image
- [] - Contains alt text (for accessibility)
- () - Contains the image URL
- "" - Optional title shown on hover
Reference-style Images
![Company Logo][logo]
![Profile Picture][avatar]
[logo]: company-logo.png "Our Logo"
[avatar]: profile.jpg 'Profile Picture'
Reference-style images help maintain cleaner, more organized Markdown
Image Dimensions and HTML Attributes
<img src="image.jpg" width="300" height="200" alt="Sized image" />
<img src="image.jpg" align="right" alt="Right-aligned image" />
Note: Some Markdown processors support HTML for advanced image formatting
Clickable Images
Advanced Features
Image Paths



- β’ Relative paths for local repository images
- β’ Absolute paths for root-relative images
- β’ Full URLs for external images
Best Practices
- π―Meaningful Alt Text
Always provide descriptive alternative text for accessibility
- πOptimize Images
Compress images and use appropriate dimensions for web use
- πOrganized Structure
Keep images in a dedicated directory with clear naming
- πSecure Sources
Use HTTPS URLs for external images when available
Accessibility Guidelines
- β’ Use descriptive alt text that conveys the image's purpose
- β’ Make decorative images empty alt="" to avoid screen reader noise noise
- β’ Ensure sufficient color contrast in images with text
- β’ Provide text alternatives for complex infographics
Common Mistakes
- β

Missing alt text reduces accessibility
- β
![Alt text] (image.jpg)
Space between brackets and parentheses breaks the image
- β
![Image of a cat]
Missing image source URL
Blockquotes π
Blockquotes in Markdown are perfect for highlighting quotes, excerpts, or important notes. They help break up text and draw attention to key information using simple > syntax.
Basic Blockquotes
> This is a simple blockquote in Markdown.
> It can span multiple lines.
> Each line needs a '>' character.
> You can also write a blockquote
on multiple lines without repeating
the '>' character on each line.
This is a simple blockquote in Markdown.
It can span multiple lines.
Each line needs a > character.
You can also write a blockquote on multiple lines without repeating the > character on each line.
Nested Blockquotes
> First level quote
>> Nested quote
>>> Deeper nested quote
> Back to first level
First level quoteNested quoteBack to first levelDeeper nested quote
Blockquotes with Other Elements
> ### Header in blockquote
>
> * List item in quote
> * Another item
>
> **Bold text** and *italic text* in quote
>
> `code` in blockquote
Header in blockquote
- List item in quote
- Another item
Bold text and italic text in quote
code
in blockquote
Common Use Cases
Citations
> The only way to do great work is to love what you do.
>
> -- Steve Jobs
The only way to do great work is to love what you do.
-- Steve Jobs
Note Callouts
> **Note:** This is an important callout.
> Please pay attention to these details.
> They are crucial for understanding.
Note: This is an important callout.
Please pay attention to these details.
They are crucial for understanding.
Best Practices
- π―Proper Spacing
Add blank lines before and after blockquotes for clarity
- πConsistent Formatting
Maintain consistent quote marker style throughout your document
- πClear Attribution
Always cite sources when quoting external content
- π¨Meaningful Usage
Use blockquotes purposefully, not just for visual effect
Common Mistakes
- β
>No space after marker
Always add a space after the > symbol
- β
Missing blank lines
Separate blockquotes from other content
- β
Inconsistent markers
Use the same number of > symbols for each nesting level
Code Blocks and Syntax Highlighting π¨βπ»
Markdown makes it easy to display both inline code and code blocks with optional syntax highlighting. Whether you're writing documentation, tutorials, or sharing code snippets, Markdown provides flexible options for code formatting.
Inline Code
Use `backticks` for inline code
The `console.log()` function outputs to the console
Use backticks
for inline code
The console.log()
function outputs to the console
Basic Code Blocks
Indent with 4 spaces or 1 tab:
function greet(name) {
console.log("Hello, " + name + "!");
}
greet("World");
function greet(name) {
console.log("Hello, " + name + "!");
}
greet("World");
Fenced Code Blocks
Fenced code blocks use triple backticks and optionally specify the programming language:
```javascript
const calculateArea = (width, height) => {
return width * height;
};
console.log(calculateArea(5, 3)); // 15
```
const calculateArea = (width, height) => {
return width * height;
};
console.log(calculateArea(5, 3)); // 15
```python
def factorial(n):
if n <= 1:
return 1
return n * factorial(n - 1)
print(factorial(5)) # 120
```
def factorial(n):
if n <= 1:
return 1
return n * factorial(n - 1)
print(factorial(5)) # 120
Syntax Highlighting
Common language identifiers include:
- β’ javascript, js
- β’ python, py
- β’ html
- β’ css
- β’ typescript, ts
- β’ jsx, tsx
- β’ json
- β’ bash, shell
- β’ sql
- β’ yaml
- β’ markdown, md
- β’ diff
Advanced Features
Line Highlighting
```javascript {2-4} showLineNumbers
function example() {
// This line is highlighted
const x = 42;
return x;
}
```
Diff Blocks
```diff
- const oldFunction = (x) => x;
+ const newFunction = (x) => x * 2;
```
Best Practices
- π―Specify Language
Always specify the programming language for proper syntax highlighting
- πMaintain Indentation
Keep code properly indented for readability
- π‘Add Comments
Include relevant comments to explain complex code sections
- βοΈKeep it Concise
Show only relevant parts of the code for examples
Common Mistakes
- β
Missing language identifier
Always specify the programming language for proper highlighting
- β
Inconsistent spacing
Maintain consistent indentation throughout code blocks
- β
Missing closing backticks
Ensure code blocks are properly closed with triple backticks
Documentation Tips
- β’ Include example input and output
- β’ Show error cases and handling
- β’ Provide context with comments
- β’ Use meaningful variable names
- β’ Break down complex examples
Tables π
Markdown tables allow you to organize data in rows and columns. While the syntax is straightforward, it supports features like column alignment and text formatting within cells.
Basic Tables
| Header 1 | Header 2 | Header 3 |
|----------|-----------|-----------|
| Cell 1 | Cell 2 | Cell 3 |
| Cell 4 | Cell 5 | Cell 6 |
Header 1 | Header 2 | Header 3 |
---|---|---|
Cell 1 | Cell 2 | Cell 3 |
Cell 4 | Cell 5 | Cell 6 |
Note: The number of hyphens in the separator row doesn't matter, but there must be at least three hyphens for each column.
Column Alignment
Control alignment using colons in the separator line:
| Left | Center | Right |
|:-----|:------:|------:|
| 1 | 2 | 3 |
| 4 | 5 | 6 |
Left | Center | Right |
---|---|---|
1 | 2 | 3 |
4 | 5 | 6 |
- :---- (Left align - default)
- :---: (Center align)
- ----: (Right align)
Formatting Within Tables
| Format | Example | Description |
|---------|---------|-------------|
| **Bold** | Text | Strong emphasis |
| *Italic* | Text | Emphasis |
| `Code` | Text | Inline code |
| [Link](url) | Text | Hyperlink |
Format | Example | Description |
---|---|---|
Bold | Text | Strong emphasis |
Italic | Text | Emphasis |
Code | Text | Inline code |
Link | Text | Hyperlink |
Table Organization Tips
- πConsistent Column Widths
Keep cell content and separator lines aligned for better readability
- πClear Headers
Use descriptive column headers that explain the data
- πLogical Grouping
Organize related data in adjacent columns
- βοΈAppropriate Alignment
Use left align for text, right align for numbers
Common Mistakes
- β
Missing header row
Always include a header row for clarity
- β
Inconsistent columns
Ensure each row has the same number of columns
- β
Missing separators
Include proper separator rows with at least three hyphens
Best Practices
- π―Keep Tables Simple
Use tables for data that naturally fits a grid format
- πConsistent Formatting
Maintain consistent alignment and spacing throughout the table
- πUse Headers Effectively
Make column headers clear and descriptive
- πReadable Content
Keep cell content concise and easy to scan
Best Practices and Tips π‘
Following consistent Markdown practices ensures your documents are readable, maintainable, and accessible. Here's a comprehensive guide to writing effective Markdown content.
Document Structure
- πConsistent Headers
Start with a single H1 (#), followed by logical heading levels. Don't skip levels.
- πClear Sections
Use headers to create distinct sections. Add blank lines between sections.
- πTable of Contents
For longer documents, include a table of contents with anchor links.
Formatting Guidelines
- β¨Consistent Formatting
Choose one style for emphasis (* or _) and stick to it throughout.
- βοΈLine Length
Keep lines under 80 characters for better readability.
- π€Lists Formatting
Use consistent list markers and proper indentation for nested lists.
Accessibility Considerations
- π―Descriptive Links
Use meaningful link text instead of "click here" or "read more".
- πΌοΈAlt Text
Provide descriptive alt text for all images and diagrams.
- πHeading Structure
Maintain proper heading hierarchy for screen readers.
Content Management
- πFile Organization
Use clear file names and organize content in logical folders.
- πVersion Control
Use Git or similar tools to track document changes.
- πRegular Review
Periodically review and update content for accuracy.
Tools and Workflow
Recommended Editors
- β’ Visual Studio Code with Markdown extensions
- β’ Typora for WYSIWYG editing
- β’ Obsidian for note-taking
- β’ StackEdit for online editing
Useful Tools
- β’ Markdown linters for consistency
- β’ Preview tools for rendering
- β’ Image optimization tools
- β’ Git for version control
Common Pitfalls to Avoid
- βInconsistent Formatting
Mixing different styles for emphasis or lists
- βPoor Organization
Lack of clear structure or logical flow
- βNeglecting Accessibility
Missing alt text or proper heading structure
Pro Tips
- β’ Preview your content before publishing
- β’ Use keyboard shortcuts for common formatting
- β’ Keep a reference guide handy
- β’ Practice writing Markdown regularly
- β’ Join Markdown communities for tips