Osi
Osi

Reputation: 1

Markdown: How to create ordered lists?

I want to create a simple ordered list in Markdown, just as the <ul><li></li></ul> in HTML but I find now way to do so anywhere I tried to read about it.

I tried for example:

- firstNum
- secondNum

+ firstNum
+ secondNum

I hoped to get 1, and 2, but sadly didn't get this in the GitHub preview.

Is there really no way to create simple ordered lists in Markdown? Must I use HTML (which I don't want)? Any idea on this?

Upvotes: 16

Views: 33642

Answers (1)

str
str

Reputation: 44979

The answer to this question can easily be found in the official Markdown documentation:

Ordered lists use numbers followed by periods:

1.  Bird
2.  McHale
3.  Parish

It’s important to note that the actual numbers you use to mark the list have no effect on the HTML output Markdown produces. The HTML Markdown produces from the above list is:

<ol>
<li>Bird</li>
<li>McHale</li>
<li>Parish</li>
</ol>

If you instead wrote the list in Markdown like this:

1.  Bird
1.  McHale
1.  Parish

or even:

3. Bird
1. McHale
8. Parish

you’d get the exact same HTML output. The point is, if you want to, you can use ordinal numbers in your ordered Markdown lists, so that the numbers in your source match the numbers in your published HTML. But if you want to be lazy, you don’t have to.

If you do use lazy list numbering, however, you should still start the list with the number 1. At some point in the future, Markdown may support starting ordered lists at an arbitrary number.

Upvotes: 35

Related Questions