在 xhtml 1.0 中,hn(h1 到 h6)必须表示文档结构,就像书中的章节一样,它们都源自
body
。
在 html5 中,有 section
、article
、header
、hgroup
,并且 hn 标签似乎是从这些标签之一派生出来的,并且与 body 元素无关。
喜欢
<html>
<body>
<h1>My personal homepage</h1>
<section id="resume">
<header>
<h1>My resumre</h1>
<p>A brief description of my skills</p>
</header>
<!-- bla bla bla -->
</section>
</body>
在 xhtml 1.0 中我会这样做:
<html>
<body>
<h1>My personal homepage</h1>
<div id="resume">
<h2>My resumre</h2>
<p>A brief description of my skills</p>
<!-- bla bla bla -->
</div>
</body>
有道理吗?或者我应该遵循与 xhtml 1.0 相同的规则并忽略部分、标题等...并使 hn 标签相对于 body 元素?
有关语义和 SEO 的建议和答案对我来说最有价值。
最好的SEO就是有好的内容,就这么简单!从语义上讲,您在这里所说明的内容很好。 HTML5 中的新功能是像
<footer>
、<header>
、<section>
和 <article>
这样的容器可以说有自己的内部结构。所以你的第一个例子的轮廓是:
如果您要将标记更改为:
<html>
<body>
<h1>My personal homepage</h1>
<h2>Introduction</h2>
<p id="intro">...</p>
<h2>About me</h2>
<section id="resume">
<header>
<h1>My resume</h1>
<h2>Overview</h2>
</header>
<p>...</p>
</section>
</body>
</html>
大纲是:
参见草案第4.4.11节的解释。 Geoffrey Sneddon 制作了 HTML 5 Outliner 工具来检查页面的轮廓。
从语义上讲,你所做的一切都很好。也许该部分应该是一篇文章。
SEO 可能还可以,但我不能肯定地说。