【发布时间】:2026-02-04 20:25:01
【问题描述】:
我对在 html5 中使用 h1-h6 标题和 section 感到困惑。
这两个例子哪个是正确的?
<body>
<article>
<header>
<h1>Article heading</h1>
<p><time>0/0/00</time></p>
<div id="article-tags"></div>
</header>
<section>
<h2>Introduction</h2>
<p> ... text ... </p>
</section>
<section>
<h2>The problem itself</h2>
<p> ... text ... </p>
</section>
</article>
</body>
这对我来说似乎很自然,将文章分成几个部分并根据整篇文章的标题层次给它们标题,但是
<body>
<article>
<header>
<h1>Article heading</h1>
<p><time>0/0/00</time></p>
<div id="article-tags"></div>
</header>
<section>
<h1>Introduction</h1>
<p> ... text ... </p>
</section>
<section>
<h1>The problem itself</h1>
<p> ... text ... </p>
</section>
</article>
</body>
我已经看到这个用了很多时间,并且读到每个部分都应该有自己的标题层次结构。
如果第二个例子是正确的,标题从h2 到h6 的目的是什么?如果每个h2 可以在新的section 中分离,并且应该有自己的标题层次结构,再次以h1 开头,是否应该使用比h1 更低的标题(因为它们都可以有自己的标题部分) ?
【问题讨论】:
-
第一个例子,只使用一次
<h1> -
@Mr.Alien:not in HTML5.
标签: html html-heading