Html 作为主要部分的部分

Html 作为主要部分的部分,html,semantic-markup,Html,Semantic Markup,使用section元素作为页面的主要内容节在语义上正确吗 可以,但我鼓励您使用新的main元素 e、 g 请参见和。概括地说,否 : 我们一直在做的错误是使用section包装内容,以便对其进行样式设置,或者将主要内容区域与导航、页眉、页脚等分开。这些是div的作业,而不是section 自从那篇文章写完后,元素就被发明出来了,用于您的确切用例。您可以说,只要您有一个标题h1-h6,而不是一个剖切元素的标题,您就可以隐式地使用section 所以这两个文档在语义上是等价的: 一, 因此,我建议:

使用section元素作为页面的主要内容节在语义上正确吗

可以,但我鼓励您使用新的main元素

e、 g

请参见和。

概括地说,否

:

我们一直在做的错误是使用section包装内容,以便对其进行样式设置,或者将主要内容区域与导航、页眉、页脚等分开。这些是div的作业,而不是section


自从那篇文章写完后,元素就被发明出来了,用于您的确切用例。

您可以说,只要您有一个标题h1-h6,而不是一个剖切元素的标题,您就可以隐式地使用section

所以这两个文档在语义上是等价的:

一,

因此,我建议:如果有疑问,请明确使用章节/文章作为页面的主要内容。

:广义上说,是的。否则,你就不能有一个单独的页眉/页脚,只属于主要内容而不是整个页面。
<main role="main">

</main>
<body>
  <h1>John's cool site</h1>
  <nav>…</nav>
  <h2>A nice article</h2> <!--- main content starts with this heading -->
  <p>I like bees.</p>
</body> <!-- main content ends at the end of the document -->
<body>
  <h1>John's cool site</h1>
  <nav>…</nav>
  <section><!--- main content starts with this opening tag -->
    <h2>A nice article</h2> <!-- now you could use h1 here, too --> 
    <p>I like bees.</p>
  </section><!-- main content ends with this closing tag -->
</body>
<body>
  <h1>John's blog</h1>
  <article>
    <h1>My first blog post</h1>
    <p>…</p>
    <footer> <!-- applies to the blog post only (article) -->
      Tags: introduction, aboutme
    </footer> 
  </article>
  <footer> <!-- applies to the whole page (body) -->
    Blog of John Doe — 2013
    <p><small>All content licensed under Creative Commons</small></p>
  </footer>
</body>