css - HTML5 语义 - 在一个部分中包含页面标题

标签 css html

我试图组织一个页面布局,在页面顶部有一个大的“英雄”部分,其中包括页面标题。

据我所见,英雄应该独立成自己的<section> .但是根据 W3 验证器,<section>不应包含 <h1>标记,因为它是顶级标题。

我应该如何在英雄中显示页面标题?

<body>

  <header>
    <nav>
    </nav>
  </header>

  <main>
    <section class="hero">
      <h1>Page title</h1>
    </section>
    <section class="content">
      <p>The page's content</p>
    </section>
  </main>

  <footer>
  </footer>

</body>

最佳答案

搜索机器人考虑 h1元素作为页面内容所属的重要排名指标以及它如何与页面等其他排名指标相关title标签,meta标签和其他模式 - 所以如果排名很重要,永远不要排除 h1

考虑使用 <header>改为标记:

<header>
  <h1>Main Page Title</h1>
  <img src="mdn-logo-sm.png" alt="MDN logo">
</header>

The element is not sectioning content and therefore does not introduce a new section in the outline. That said, a header element is intended to usually contain the surrounding section's heading (an h1–h6 element), but this is not required.

来源:<header> HTML | MDN

关于css - HTML5 语义 - 在一个部分中包含页面标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46345007/

相关文章:

html - Marquee - 行分成两行而不是单行 - css

jQuery carousel new style next 和 prev 在第一张和最后一张幻灯片上

c# - 无法检查用户是否已存在于我的数据库中

html - 并排添加具有相同类的两个列 div 之间的间隙

javascript - 如何获得 <li> 标签的所有 parent 点击它?

css - 单击按钮更改响应和无响应的站点

css - 如何 CSS 选择除 IE7/8 上的最后一个单元格之外的所有单元格?

javascript - 将颜色框添加到图像 onClick

javascript - 将鼠标悬停在不同的文本上时更改文本的颜色?

javascript - 下拉菜单没有关闭?