HTML <br>
元素會產生文字的斷行(carriage-return、CR 或是確認鍵)。此元素主要用於寫詩或寫住址,這種斷行有所意義的時候。
內容類型 | 流型內容、段落型內容。 |
---|---|
允許內容 | 無,這是個空元素. |
標籤省略 | 絕對要有開啟標籤,也絕不能關閉標籤。在 XHTML 文件內,要把這個元素寫成 <br /> . |
允許父元素 | 任何接受段落型內容的元素 |
允許的 ARIA roles | 所有 |
DOM 介面 | HTMLBRElement |
屬性
這個元件屬性含有全域屬性。
註解
不要使用 <br>
來增加文字間距,你應該用 CSS 的 margin
屬性、或改用 <p>
元素以完成這件事。
示例
Mozilla Foundation<br> 1981 Landings Drive<br> Building K<br> Mountain View, CA 94043-0801<br> USA
以上 HTML 將顯示
Mozilla Foundation
1981 Landings Drive
Building K
Mountain View, CA 94043-0801
USA
規範
規範 | 狀態 | 註解 |
---|---|---|
HTML Living Standard The definition of '<br>' in that specification. |
Living Standard | |
HTML5 The definition of '<br>' in that specification. |
Recommendation | |
HTML 4.01 Specification The definition of '<br>' in that specification. |
Recommendation |
瀏覽器相容性
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 1 | Yes | 1 | Yes | Yes | Yes |
clear | 1 | Yes | 1 | Yes | Yes | Yes |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | Opera Android | iOS Safari | Samsung Internet |
---|---|---|---|---|---|---|---|
Basic support | Yes | Yes | Yes | 4 | Yes | Yes | Yes |
clear | Yes | Yes | Yes | 4 | Yes | Yes | Yes |