标题标签是否应嵌套在标签内?

时间:2016-02-02 17:34:51

标签: html

这是正确的方法吗?



<section>
         <h2>Chapter 1</h2>
         <p>In this chapter we will....</p>
</section>
&#13;
&#13;
&#13;

或者是这个?

&#13;
&#13;
<h2>Chapter 1</h2>
<section>
    <p>In this chapter we will....</p>
</section>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

点击此链接:https://www.w3.org/wiki/HTML/Elements/section

在这些例子中,他们使用:

<article>
 <hgroup>
  <h1>Apples</h1>
  <h2>Tasty, delicious fruit!</h2>
 </hgroup>
 <p>The apple is the pomaceous fruit of the apple tree.</p>
 <section>
  <h1>Red Delicious</h1>
  <p>These bright red apples are the most common found in many
  supermarkets.</p>
 </section>
 <section>
  <h1>Granny Smith</h1>
  <p>These juicy, green apples make a great filling for
  apple pies.</p>
 </section>
</article>

建议组织,例如:article&gt; section&gt; h1 + p。我认为这是一种合适的方法。

引用W3

  

section元素表示文档的通用部分或   应用。在这方面,一节是一个主题分组   内容。应通过以下方式确定每个部分的主题   包括标题(h1-h6元素)作为section元素的子元素。

答案 1 :(得分:0)

section就像article一样,就像将所有内容放在外部标题下方一样。作为示范,说你有这个。

<h1>Heading</h1>
<h6>Small Heading</h6>
<section>
    <h1>Section Heading</h1>
</section>

该文件的大纲实际上是:

  • 航向
    • 小标题
      • 章节标题

即使h1低于h6section也会开始一个子文档。

http://html5doctor.com/the-section-element/上的文章说:

  

请注意,标题位于section元素内,而不是紧接在

之前

所以,你的第一个例子可能是正确的。