HTML5结构和章节或文章中的标题

前端之家收集整理的这篇文章主要介绍了HTML5结构和章节或文章中的标题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
虽然我真的应该知道这一点,但我担心我不能完全理解.阅读过不同的文章,阅读书籍并与其他人交谈后,我仍然不太了解 HTML5部分的正确结构.在每个部分和/或文章中都有一个h1标签是否合适?新的部分或文章是否构成了再次启动h1到h2的过程?

我的印象是每个“块”应该被允许它自己的“标题”结构.

例如,这是正确的HTML5吗? :

<!doctype html>
<html>
  <head>
    <title>
    <!-- etc. etc. -->

    <body>
      <section> <!-- two or more <articles> within this section,both using <h1> tags -->
        <h1>Here is a section with articles in</h1>
        <article>
          <h1>Heading</h1>
          <h2>sub heading</h2>
          <p>A paragraph>
        </article>
        <article>
          <h1>Heading</h1>
          <h2>sub heading</h2>
          <p>A paragraph</p>
        </article>
        ...      
      </section>
      <section> <!-- two or more <articles> within this additional section,both using <h1> tags -->
        <h1>Here is a section with articles in</h1>
        <article>
          <h1>Heading</h1>
          <h2>sub heading</h2>
          <p>A paragraph>
        </article>
        <article>
          <h1>Heading</h1>
          <h2>sub heading</h2>
          <p>A paragraph</p>
        </article>
        ...      
      </section>                  
    </body>
</html>

解决方法

由于文章中的每对h1和h2元素分别代表一个标题和一个副标题,因此您需要将该对分组到文章中自己的标题中,以便为每篇文章生成正确的文档大纲.

除此之外,您的部分的标题结构似乎很好.

猜你在找的HTML5相关文章