【问题标题】:How to use H tags correctly if child elements are more important than parents如果子元素比父元素更重要,如何正确使用 H 标签
【发布时间】:2014-10-20 20:33:59
【问题描述】:

我正在将我的一个旧网站更新为 html5,即使在阅读了很多文章后,我还是有点困惑,如何正确使用 h 标签。

正如标题所说,孩子比父母更重要,所以在我的示例代码中,最重要的是文章标题而不是副标题,最不重要的是章节主标题。

<html>
<head>
<!-- head stuff here-->
</head>
<body>
<header>
<!-- site name and logo and sitenav is here -->
</header>
<div id="section1">
  <div class="this_should_be_h_tag">
  Section 1 Main title
  <!-- for example this section is Called MENU (like restaurant menu) -->
  </div>
  <div id="section1_1">
    <div class="this_should_be_h_tag">
    Sub title 1
    <!-- for example this sub section is called HAMBURGERS -->
    </div>
    <article>
      <header>
        <h1>
        Article title
        <!-- lets say this is called BBQ Burger -->
        </h1>
      </header>
      <div class="article-body">
      <!-- here is the description of the BBQ Burger -->
      </div>
      <footer></footer>
    </article>
    <article>
      <header>
        <h1>
        Article title
        <!-- lets say this is called Vega Burger -->
        </h1>
      </header>
      <div class="article-body">
      <!-- here is the description of the Vega Burger -->
      </div>
      <footer></footer>
    </article>
  </div>

  <div id="section1_2">
    <div class="this_should_be_h_tag">
    Sub title 2
    <!-- for example this sub section is called SPECIALITIES -->
    </div>
    <article>
      <header>
        <h1>
        Article title
        <!-- lets say this is called Jalapeno Poppers -->
        </h1>
      </header>
      <div class="article-body">
      <!-- here is the description of the Jalapeno Poppers -->
      </div>
      <footer></footer>
    </article>
    <article>
      <header>
        <h1>
        Article title
        <!-- lets say this is called Duckets -->
        </h1>
      </header>
      <div class="article-body">
      <!-- here is the description of the Duckets -->
      </div>
      <footer></footer>
    </article>
  </div>
</div>
<footer>
<!-- footer stuff here -->
</footer>
</body>
</html>

那么在这样的结构中,正确的路径是什么?我可以这样做:section main title=h3, subtitle=h2, and article title=h1?

哦,我差点忘了网站标题也是用 h1 标签包裹的。

编辑: 所以我添加了一些 HTML 注释来澄清它。 我希望现在很清楚文章是最重要的内容,第二个是Sub titleSection Main title 只是一个组名,从 seo 的角度来看可能完全无关,但它在我不知道的原始设计中不想改变。

【问题讨论】:

  • 看起来很简单。 H1 最重要,H6 最不重要。根据需要设置样式。
  • 好的,所以如果我按照我写的那样做 h3 > h2 > h1 顺序从 seo 的角度来看不会是错误的吗?
  • 章节主标题应该是h1,副标题应该是h2,文章标题应该是h3(或者只是标题)
  • 完全不清楚页面的实际结构是什么,“重要性”是什么意思,“正确”是什么意思。此外,依赖“HTML5 大纲”(这就是代码似乎正在做的事情)是没有意义的。
  • @Jukka K. Korpela 这是实际的结构,只是去掉了与这个问题无关的代码。在重要性方面,我的意思是它对它自己的网站很重要,对 seo 也很重要。我会将 html cmets 中的实际内容和 cmets 放入我上面的代码中,以使其更清晰,直到我在 superUntitled's 的评论中写了一个示例@答案

标签: html


【解决方案1】:

第 1 部分的主要内容应该是您的 h1。字幕应为h2。文章标题h3

搜索引擎会正确索引您的网站。只需确保您的部分和子部分标题命名有意义即可。

【讨论】:

  • 好的,但遗憾的是第 1 节的主要内容是最没有意义的。这是一个具体的例子:Section 1 title=Menu,Subtitle 1=hamburgers,文章标题当然是汉堡的名字。因此,没有人会用“菜单”关键字搜索汉堡。这就是为什么我想要一个反向订单。但看起来我将不得不改变结构,或者可能完全放弃第 1 节的标题,或者干脆把它放在一个段落或跨度中
猜你喜欢
  • 2011-07-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-25
  • 2018-12-08
  • 1970-01-01
相关资源
最近更新 更多