Markdown list indentation with 3 spaces or 4 spaces? What is the standard?

Viewed 1154

I have googled this for hours. But different people give different answers. Some people say 4 spaces is the standard and some people say 3 spaces is the standard for markdown. I am very confused. Can anyone please simply tell me what is the recommended standard? Thanks.

  • how many spaces
    • should I use
      • here?

I know 2 spaces, 3 spaces and 4 spaces are all working. But I just want to know what the formal standard is. Thank you very much.

1 Answers

The closest thing markdown has to a standard is CommonMark, which has a list definition that allows:

a list marker of width W followed by 1 ≤ N ≤ 4 spaces

For unordered lists, I've seen most people to use two spaces. But it's really personal preference.

- foo
  - bar

In CommonMark, you have to indent at least as much as the first character that's not part of the list marker and not whitespace (i.e. the f in the above example).

So for ordered lists, you have to indent at least three, so most people go with four, which also works when you hit the list marker 10.

 9. foo
10. foo
    1. bar
Related