HTML <hr>
元素表示段落级元素之间的主题转换(例如,一个故事中的场景的改变,或一个章节的主题的改变)。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
在HTML的早期版本中,它是一个水平线。现在它仍能在可视化浏览器中表现为水平线,但目前被定义为语义上的,而不是表现层面上。所以如果想画一条横线,请使用适当的css样式来修饰。
要更改 <hr> 与段落之间的间隙或样式,请使用 CSS。
- 内容分类 流式元素.
- 允许的内容无, 是一个 空元素.
- 标签省略必须有开始标签, 不能有结束标签。
- 允许的父元素 所有接受流式元素的元素。
- DOM接口
HTMLHRElement
属性
该元素包含全局属性
align
- 设置对齐方式. 如果没有值, 默认值为
left。
color
- 使用颜色名或十六进制设置颜色。
noshade
- 去除阴影。
size
- 使用像素设置高度。
width
- 使用像素或者百分比设置宽度。
示例
HTML
<p>
This is the first paragraph of text.
This is the first paragraph of text.
This is the first paragraph of text.
This is the first paragraph of text.
</p>
<hr>
<p>
This is the second paragraph of text.
This is the second paragraph of text.
This is the second paragraph of text.
This is the second paragraph of text.
</p>
结果
规范
规范 | 状态 | 备注 |
---|---|---|
HTML Living Standard <hr> |
Living Standard | Definition of the hr element |
HTML Living Standard | Living Standard | Suggested default rendering of the hr element |
HTML5 <hr> |
Recommendation | |
HTML 4.01 Specification <hr> |
Recommendation |
浏览器兼容性
BCD tables only load in the browser
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.