List in Markdown
A list is a collection of one or more items. It is used to display the information in a well-formed manner.
The list provides a format that is easy to read.
Unlike HTML Markdown provide this feature with simple syntax.
There are 2 types of listing methods.
- Ordered List
- Unordered List
List in Markdown
Ordered List
An ordered list provides a list with number formate followed by a dot .
.
Example for an ordered list
1. First Item
2. Second Item
3. Third Item
<ol>
<li> First item </li>
<li> Second item </li>
<li> Third item </li>
</ol>
Output for ordered list
- First Item
- Second Item
- Third Item
Example for ordered list same number
Even if we specify the same number, List will automatically convert it sequentially like
1. First Item
1. Second Item
1. Third Item
Output for same number
- First Item
- Second Item
- Third Item
Example for ordered nested list items
To display a nested item we can simply use a tab and it will treat that item as a nested item of the above item.
1. First Item
2. Second Item
1. nested Item 1
2. nested Item 2
3. Third Item
<ol>
<li> First Item</li>
<li> Second Item
<ol>
<li> nested item 1 </li>
<li> nested item 2 </li>
</ol>
</li>
<li>Third Item</li>
</ol>
Output for ordered nested list items
- First Item
- Second Item
- nested Item 1
- nested Item 2
- Third Item
Unordered List
Unordered List provides a list with simple bullets.
It is used when the sequence is not important. All the items listed in the list are may not be logically related to each other.
- to display an unordered list we can use dashed (
-
), asterisks(*
), plus sign(+
).
Example for unordered list
- item 1
* item 2
- item 3
<ul>
<li> item 1 </li>
<li> item 2 </li>
<li> item 3 </li>
</ul>
Output for unordered list
- item 1
- item 2
- item 3
Example for unordered nested list items
To display a nested item we can simply use a tab and it will treat that item as a nested item of the above item.
- item 1
- item 2
- nested item 1
- nested item 2
- item 3
<ul>
<li> First Item</li>
<li> Second Item
<ul>
<li> nested item 1 </li>
<li> nested item 2 </li>
</ul>
</li>
<li>Third Item</li>
</ul>
Output for unordered nested list items
- First Item
- Second Item
- nested Item 1
- nested Item 2
- Third Item
Unordered List Best Practices
For compatibility, don’t mix delimiters in the same list — pick one and stick with it.
✅ Do | ❌ Don’t |
---|---|
- First item | + First item |
- Second item | * Second item |
- Third item | - Third item |
- Fourth item | + Fourth item |
Hope you like this!
Keep helping and happy 😄 coding