钟神秀

所有的为时已晚都是恰逢其时

钟神秀 avatar

Author

钟神秀

大三学生 · 博客写作者

Telegram

我的频道

不定期推送灵感笔记

t.me/zsxcoder
联系方式
QQ
3149261770
发送邮件
Markdown 换行语法

Markdown 换行语法

Markdown 换行语法,如何创建换行以及最佳实践

钟神秀
钟神秀 大学牛马
2025年06月28日
预计阅读 2 分钟
442 字

原文链接: https://markdown.com.cn/basic-syntax/line-breaks.html

Markdown 换行语法

在一行的末尾添加两个或多个空格,然后按回车键,即可创建一个换行(<br>)。

Markdown语法HTML预览效果
This is the first line.
And this is the second line.
This is the first line.<br>
And this is the second line.
This is the first line.
And this is the second line.

换行(Line Break)用法的最佳实践

几乎每个 Markdown 应用程序都支持两个或多个空格进行换行,称为 结尾空格(trailing whitespace) 的方式,但这是有争议的,因为很难在编辑器中直接看到空格,并且很多人在每个句子后面都会有意或无意地添加两个空格。由于这个原因,你可能要使用除结尾空格以外的其它方式来换行。幸运的是,几乎每个 Markdown 应用程序都支持另一种换行方式:HTML 的 <br /> 标签。

为了兼容性,请在行尾添加“结尾空格”或 HTML 的 <br> 标签来实现换行。

还有两种其他方式我并不推荐使用。CommonMark 和其它几种轻量级标记语言支持在行尾添加反斜杠 (\) 的方式实现换行,但是并非所有 Markdown 应用程序都支持此种方式,因此从兼容性的角度来看,不推荐使用。并且至少有两种轻量级标记语言支持无须在行尾添加任何内容,只须键入回车键(return)即可实现换行。

✅ Do this❌ Don’t do this
First line with two spaces after.
And the next line.
First line with a backslash after.\
And the next line.
First line with the HTML tag after.<br>
And the next line.
First line with nothing after.
And the next line.

觉得这篇文章怎么样?

点个赞,让更多人看到!

分享这篇文章

知识因分享而增值

分类

技术分享

标签

markdown语法
教程

版权声明:本文作者为 钟神秀,首发于www.zsxcoder.top

遵循 CC BY-NC-SA 4.0 许可协议。转载请注明出处!