这篇翻译不完整。请帮忙从英语翻译这篇文章。
HTML <h1>
–<h6>
标题(Heading)元素呈现了六个不同的级别的标题,<h1>
级别最高,而 <h6>
级别最低。一个标题元素能简要描述该节的主题。标题信息可以由用户代理可以使用,例如,自动构造某个文档中的内容表(就像本文档右边浮动栏一样)。
使用要点:
- 不要为了减小标题的字体而使用低级别的标题, 而是使用 CSS
font-size
属性。 - 避免跳过某级标题:始终要从
<h1>
开始,接下来依次使用<h2>
等等。 - 使用
<section>
元素时,为了方便起见,你应该考虑避免在同一个页面上重复使用 <h1>,<h1> 应被用于表示页面的标题,其他的标题当从 <h2> 开始。在使用 section 时,应当为每个 section 都使用一个<h2>
。详情请参考 Defining sections in Using HTML sections and outlines。
内容类别 | 流内容, 标题内容,可触知的内容。 |
---|---|
允许内容 | 短语内容 |
标签省略 | 不允许,开始标签和结束标签都不能省略。 |
允许的父元素 | 任何接受流内容的元素;不要把它作为 <hgroup> 元素的子元素, 这种做法已经被废弃了。 |
DOM 接口 | HTMLHeadingElement |
属性
该元素包含所有全局特性.
align属性已废弃;不要继续使用它。
所有标题
下面的代码展示了所有可用的标题级别。
<h1>一级标题</h1> <h2>二级标题</h2> <h3>三级标题</h3> <h4>四级标题</h4> <h5>五级标题</h5> <h6>六级标题</h6>
下面是这些代码的结果:
示例页面
下面的代码展示了几个具有部分内容的标题。
<h1>Heading elements</h1> <h2>Summary</h2> <p>Some text here...</p> <h2>Examples</h2> <h3>Example 1</h3> <p>Some text here...</p> <h3>Example 2</h3> <p>Some text here...</p> <h2>See also</h2> <p>Some text here...</p>
下面是代码的运行结果:
规范
Specification | Status | Comment |
---|---|---|
HTML Living Standard <h1>, <h2>, <h3>, <h4>, <h5>, and <h6> |
Living Standard | |
HTML5 <h1>, <h2>, <h3>, <h4>, <h5>, and <h6> |
Recommendation | |
HTML 4.01 Specification <h1>, <h2>, <h3>, <h4>, <h5>, and <h6> |
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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Basic support | Chrome Full support Yes | 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 | Edge Mobile 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
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | (Yes) | 1.0 (1.7 or earlier) | (Yes) | (Yes) | (Yes) |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | (Yes) | 1.0 (1.0) | (Yes) | (Yes) | (Yes) |