订购标题标签

mar*_*cgg 2 xhtml seo semantics

我还没有找到这个问题,如果它已经在这里,请随时关闭.

你最喜欢用HTML设置标题的方式是什么?

<h1> Main Part </h1>
<h2> In here there are many sections</h2>
<div id="section1">
  <h1> Section 1 </h1>
  <h2> Subtitle </h2>
</div>
<div id="section2">
  <h1> Section 2 </h1>
  <h2> Subtitle </h2>
</div>
Run Code Online (Sandbox Code Playgroud)

要么

<h1> Main Part </h1>
<h2> In here there are many sections</h2>
<div id="section1">
  <h3> Section 1 </h3>
  <h4> Subtitle </h4>
</div>
<div id="section2">
  <h3> Section 2 </h3>
  <h4> Subtitle </h4>
</div>
Run Code Online (Sandbox Code Playgroud)

...意味着从顶部开始排序,或者从页面的每个部分开始从H1开始,这是不同的部分(/ container/sidebar/whatever).

还有其他的实践.那你喜欢哪一个?你做的甚至不同,如果是这样,怎么样?那里有最好的做法吗?这会影响SEO吗?哪一个是最具语义性的?


编辑:这里的人似乎同意第二个解决方案.这也是我的观点,但是这里引出了一个问题:如果我想在主要部分放置一个h3怎么办?

<h1> Main Part </h1>
<h2> In here there are many sections</h2>
<h3> Something else </h3>
<div id="section1">
  <h3> Section 1 </h3>
  <h4> Subtitle </h4>
</div>
<div id="section2">
  <h3> Section 2 </h3>
  <h4> Subtitle </h4>
</div>
Run Code Online (Sandbox Code Playgroud)

我是否必须重写所有部分?这可能是一个完整的网站!通常很难确切知道一节中会有多少字幕.

请记住,这些部分可能是侧边栏或看起来完全不同的东西以及页面上的其他位置.

Pet*_*ter 12

我相信每个文档只应该有一个H1元素,但我不确定这是不是一个规则.但是,我倾向于遵循这一点.

因此,我投票给你提供的第二个例子,拥有多个H3/H4等元素比多个H1元素更合乎逻辑.这意味着您尝试以更好的方式传达的层次结构.