HTML <br> 元素在文本中生成一个换行(回车)符号。此元素在写诗和地址时很有用,这些地方的换行都非常重要。
内容分类 | Flow content, phrasing content. |
---|---|
允许的内容 | 无,这是一个空元素. |
标签略写 | 必须有一个开始标签,并且一定不能有结束标签。在 XHTML中将元素写为 <br /> 。 |
允许的父元素 | 任意可容纳 phrasing content 的元素。 |
Permitted 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
The HTML above outputs:
Mozilla Foundation
1981 Landings Drive
Building K
Mountain View, CA 94043-0801
USA
技术规范
Specification | Status | Comment |
---|---|---|
HTML Living Standard <br> |
Living Standard | |
HTML5 <br> |
Recommendation | |
HTML 4.01 Specification <br> |
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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
br | Chrome Full support 1 | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
clear | Chrome Full support 1 | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.