Markdown Lists
Lists are an important way to organize information. Markdown supports ordered lists, unordered lists, and task lists. This chapter will detail various uses of lists.
Unordered Lists
Basic Syntax
Use -, +, or * to create unordered lists:
Effect:
- Item one
- Item two
- Item three
Different Markers
All three markers have the same effect:
Effect:
- Using dash
- Using plus
- Using asterisk
Best Practices
It's recommended to use the same symbol throughout the document:
Ordered Lists
Basic Syntax
Use numbers followed by . to create ordered lists:
Effect:
- First item
- Second item
- Third item
Auto Numbering
Numbers don't need to be in order, Markdown will automatically number them:
Effect:
- First item
- Second item
- Third item
Specify Starting Number
Effect:
- Fifth item
- Sixth item
- Seventh item
Nested Lists
Unordered List Nesting
Use indentation (2 or 4 spaces) to create nesting:
Effect:
- Main item
- Sub item 1
- Sub item 2
- Sub sub item 1
- Sub sub item 2
- Another main item
Ordered List Nesting
Effect:
- First item
- Sub item 1.1
- Sub item 1.2
- Second item
- Sub item 2.1
- Sub item 2.2
Mixed Nesting
Effect:
- Ordered item
- Unordered sub item
- Another unordered sub item
- Another ordered item
- Ordered sub item
- Another ordered sub item
Paragraphs in Lists
Single Paragraph
Add a paragraph in a list item, use indentation:
Multiple Paragraphs
Code Blocks in Lists
Inline Code
Effect:
- Use
git addto add files - Use
git committo commit changes - Use
git pushto push to remote
Code Blocks
Use 8 spaces or 2 tabs for indentation:
Quotes in Lists
Effect:
-
First item
This is a quoted text. Can have multiple lines.
-
Second item
Images in Lists
Task Lists
Basic Syntax
Use - [ ] and - [x] to create task lists:
Effect:
- Completed task
- Incomplete task
- Another incomplete task
Nested Task Lists
Effect:
- Main task
- Subtask 1
- Subtask 2
- Another main task
- Subtask 1
- Subtask 2
Task List Applications
Definition Lists
Some Markdown extensions support definition lists:
Or use HTML:
List Styles
Use Emojis
Effect:
- ✅ Completed
- ⏳ In Progress
- ❌ Cancelled
- 📝 Pending
Use Icons
Effect:
- 🎯 Goal
- 💡 Idea
- ⚠️ Warning
- 📌 Important
List Best Practices
1. Keep Indentation Consistent
2. Blank Lines Before and After Lists
3. Keep it Concise
4. Use Nesting Reasonably
Don't nest too deep (recommended no more than 3 levels):
List Application Scenarios
1. Step Instructions
2. Feature Lists
3. Todo Items
4. Pros and Cons Comparison
5. Directory Structure
Lists Combined with Other Elements
Lists + Links
Lists + Bold
Lists + Code
Common Questions
Spacing Between List Items
If you need more spacing between list items, add blank lines between items:
List Number Reset
If a list is interrupted by other content, numbering will reset:
Special Characters in Lists
If a list item starts with a number and a dot, escape it:
Shortcuts
VS Code
Ctrl/Cmd + Shift + ]: Increase indentationCtrl/Cmd + Shift + [: Decrease indentation
Typora
Ctrl/Cmd + ]: Increase indentationCtrl/Cmd + [: Decrease indentationCtrl/Cmd + Shift + X: Toggle task status
Practice Exercises
Try creating the following lists:
- An unordered list with 3 items
- An ordered list with 5 steps
- A list with nested items
- A task list (with completed and incomplete items)
- A list containing code and links
Summary
Lists are one of the most commonly used features in Markdown. Mastering lists can:
- Clearly organize information
- Show steps and processes
- Manage tasks and todo items
- Create tables of contents and navigation
Next: Learn detailed usage of Markdown Blockquotes.