列表
有序列表
要创建有序列表,请添加带有数字和句点的行项目。数字不必按数字顺序排列,但列表应从数字 1 开始。
Markdown | HTML | 渲染输出 |
---|---|---|
1. First item | <ol> |
|
1. First item | <ol> |
|
1. First item | <ol> |
|
1. First item | <ol> |
|
有序列表最佳实践
为了兼容性,请仅使用句点。
✅ 这样做 | ❌ 不要这样做 |
---|---|
1. First item | 1) First item |
无序列表
要创建无序列表,请在行项目前添加破折号 ( -
)、星号 ( *
) 或加号 ( )。缩进一个或多个项目以创建嵌套列表。+
Markdown | HTML | 渲染输出 |
---|---|---|
- First item | <ul> |
|
* First item | <ul> |
|
+ First item | <ul> |
|
- First item | <ul> |
|
无序列表项以数字开头
如果需要以数字加句点开始无序列表项,则可以使用反斜杠 ( \
) 来转义句点。
Markdown | HTML | 渲染输出 |
---|---|---|
- 1968\. A great year! | <ul> |
|
无序列表最佳实践
出于兼容性考虑,请勿在同一列表中混合使用分隔符 - 选择一个并坚持使用。
✅ 这样做 | ❌ 不要这样做 |
---|---|
- First item | + First item |
在列表中添加元素
要在列表中添加另一个元素同时保持列表的连续性,请将元素缩进四个空格或一个制表符,如以下示例所示。
段落
* This is the first list item.
* Here's the second list item.
I need to add another paragraph below the second list item.
* And here's the third list item.
渲染的输出如下所示:
- 这是第一个列表项。
-
这是第二个列表项。
我需要在第二个列表项下方添加另一个段落。
- 这是第三个列表项。
引用
* This is the first list item.
* Here's the second list item.
> A blockquote would look great below the second list item.
* And here's the third list item.
渲染的输出如下所示:
- 这是第一个列表项。
-
这是第二个列表项。
块引用放在第二个列表项下面会很好看。
- 这是第三个列表项。
代码块
代码块通常缩进四个空格或一个制表符。当它们在列表中时,缩进八个空格或两个制表符。
1. Open the file.
2. Find the following code block on line 21:
<html>
<head>
<title>Test</title>
</head>
3. Update the title to match the name of your website.
渲染的输出如下所示:
- 打开文件。
-
在第 21 行找到以下代码块:
<span style="color:#212529"><code> <html> <head> <title>Test</title> </head> </code></span>
- 更新标题以与您的网站名称匹配。
图片
1. Open the file containing the Linux mascot.
2. Marvel at its beauty.

3. Close the file.
渲染的输出如下所示:
- 打开包含 Linux 吉祥物的文件。
-
惊叹它的美丽。
- 关闭文件。
列表
您可以将无序列表嵌套在有序列表中,反之亦然。
1. First item
2. Second item
3. Third item
- Indented item
- Indented item
4. Fourth item
渲染的输出如下所示:
- 第一项
- 第二项
- 第三项
- 缩进项目
- 缩进项目
- 第四项