banner
克喵爱吃卤面

喵落阁

光就是一切的意义!
telegram
github
qq
email
x
bilibili

Markdown 換行語法

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

Markdown 換行語法#

在一行的末尾添加兩個或多個空格,然後按回車鍵,即可創建一個換行 (<br>)。

Markdown 語法HTML預覽效果
This is the first line.
And this is the second line.
<p>This is the first line.<br>
And this is the second line.</p>

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.
載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。