Alex Baban
Alex Baban

Reputation: 11732

How to write an ordered list which contains nested unordered lists (GitHub markdown)

From the docs here:
(https://guides.github.com/features/mastering-markdown/),
you can create a nested list by indenting one or more list items below another item.


enter image description here

But I'm trying to create an ordered list with nested unordered lists.


I tried this code:

1. Ordered One
  * Unordered First
  * Unordered Second
  * Unordered Third
1. Ordered Second
  * Unordered One
  * Unordered Two
  * Unordered Three

and what I get is this:

enter image description here


How can I write this so Ordered Second automatically gets number 2. and the unordered nested lists are properly indented?

Thank you.

Upvotes: 38

Views: 35121

Answers (1)

Daniel Gimenez
Daniel Gimenez

Reputation: 20544

The issue you are experiencing is because your top-level list numbers in your example begin with a space in front. Eliminate that space and use three spaces for the sub-level indentation.

It isn't necessary to eliminate the space as it seems the key in GitHub's markdown is that there are three spaces differentiating the levels. So if you started with one space in front, the next level would have to have four spaces from the start of the line.

1. Ordered One
   * Unordered First
   * Unordered Second
   * Unordered Third
1. Ordered Second
   * Unordered One
   * Unordered Two
   * Unordered Three
  1. Ordered One
    • Unordered First
    • Unordered Second
    • Unordered Third
  2. Ordered Second
    • Unordered One
    • Unordered Two
    • Unordered Three

Upvotes: 47

Related Questions