需要在SEO方面具有类似标题元素吗?

huangapple go评论95阅读模式
英文:

Do similar heading elements need to be on the same DOM level for SEO purposes?

问题

类似的标题标签在DOM中是否需要位于相同级别以最佳优化SEO,或者它们嵌套得多深位置是否无关紧要,只要它们按正确的顺序排列?

例如,这是我认为最佳的方式:

<h3>...</h3>
<div>与前一个h3相关的内容</div>
<h3>...</h3>
<div>与前一个h3相关的内容</div>

但出于样式目的,我可能需要以这种方式结构化HTML(甚至更多嵌套):

<div>
  <h3>...</h3>
  <div>与前一个h3相关的内容</div>
</div>
<div>
  <h3>...</h3>
  <div>与前一个h3相关的内容</div>
</div>
英文:

Do similar heading tags need to be on the same DOM level to best optimize for SEO, or does it not matter at all how deeply nested and positioned they are as long as they are in proper sequential order?

For instance, this is what I imagine to be best:

&lt;h3&gt;...&lt;/h3&gt;
&lt;div&gt;Content related to previous h3&lt;/div&gt;
&lt;h3&gt;...&lt;/h3&gt;
&lt;div&gt;Content related to previous h3&lt;/div&gt;

But for styling purposes I may need to structure html this way (or even more nested):

&lt;div&gt;
  &lt;h3&gt;...&lt;/h3&gt;
  &lt;div&gt;Content related to previous h3&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
  &lt;h3&gt;...&lt;/h3&gt;
  &lt;div&gt;Content related to previous h3&lt;/div&gt;
&lt;/div&gt;

答案1

得分: 1

搜索引擎不太关心您的标签结构。Google似乎更注重页面的呈现方式,而不是您使用的标签。最终显眼的文本比标题标签中的内容更具相关性权重。Google从未关心网站使用有效或干净的HTML代码。Google一直尝试索引所有可用的网站,而不仅仅是符合任何技术标准的网站。

即使是在语义正确方面,两种方式都可以。以下是HTML规范的相关部分:4.4.11 标题和章节 — HTML5:Web作者版本

规范表示,只有分区根元素会影响标题标签的解释方式。您可以使用任何结构的<div><span>,而不会改变页面的大纲结构。只有<blockquote><body><details><fieldset><figure><td>在确定标题标签范围时才会起作用。

英文:

You can structure your HTML either way. Search engines don't care much about your tag structure. Google seems to pay more attention to how the page renders these days than to what tags you use. The text that ends up big and prominent gets relevancy weight more than what is in heading tags. Google has never cared that sites use valid or clean HTML code. Google has always tried to index all sites that are usable rather than only those that meet any technical standard.

Even for semantic correctness, either way is fine. Here is the relevant section of the HTML spec: 4.4.11 Headings and sections — HTML5: Edition for Web Authors

It says that only sectioning roots make any difference to how your heading tags are interpreted. You can use any structure of &lt;div&gt; or &lt;span&gt; without changing the outline structure of your page. Only &lt;blockquote&gt;, &lt;body&gt;, &lt;details&gt;, &lt;fieldset&gt;, &lt;figure&gt;, or &lt;td&gt; matter when determining the scope of heading tags.

huangapple
  • 本文由 发表于 2023年3月7日 19:50:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75661622.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定