Skip to content
Lists
step 1/5

Reading — step 1 of 5

Read

~1 min readLists & Code

Lists

Unordered:

- item 1
- item 2
* item 3   (also valid)
+ item 4   (also valid)

Becomes:

<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
</ul>

Ordered:

1. first
2. second
3. third
<ol>
<li>first</li>
<li>second</li>
<li>third</li>
</ol>

Number values are mostly ignored (1. 1. 1. produces 1, 2, 3 with default OL counter).

Nested lists with indentation:

- top
  - nested
  - also nested
- back to top
<ul>
<li>top
<ul>
<li>nested</li>
<li>also nested</li>
</ul>
</li>
<li>back to top</li>
</ul>

Indentation rules vary by parser. CommonMark: nested list items are indented at least 2 spaces. Real parsers handle weird mixed lists pretty heroically.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…