我正在读马克·皮尔格姆的《深入研究 HTML5 http://www.diveintohtml5.net/semantics.html”并且在语义部分 http://www.diveintohtml5.net/semantics.html#new-elements,它讲述了 HTML5 如何引入<article>
and <section>
元素。它说<section>
s 代表通用文档或部分,而<article>
s 代表一个独立的组合。无论哪种方式,我都看不到逻辑语义上的父子关系。
我尝试通过以下代码运行HTML5 大纲视图 http://gsnedders.html5.org/outliner/这似乎表明,无论如何嵌套,文档大纲都是一样的。
所以我的问题是:应该<section>
s 嵌套在里面<article>
s,应该<article>
s 嵌套在里面<secion>
s,或者从语义的角度来看这并不重要?
<section><h1>section article?</h1>
<article><h1>art 1</h1></article>
<article><h1>art 2</h1></article>
<article><h1>art 3</h1></article>
</section>
<article><h1>article section?</h1>
<section><h1>sec 1</h1></section>
<section><h1>sec 2</h1></section>
<section><h1>sec 3</h1></section>
</article>
无论哪种方式嵌套它们都是完全可以接受的。尽管文档大纲没有区分<section>
and an <article>
,从语义的角度来看它们是两个不同的东西。这就是将它们作为两个不同的语义元素引入的全部意义。
如果您的页面包含多篇文章,请使用第一个片段。
当您的文章足够全面以包含多个部分时,请使用第二个片段。
如果两者都适合您的内容,您甚至可以将它们组合起来,这样您的标记如下所示:
<section><h1>section article?</h1>
<article><h1>art 1</h1>
<section><h1>sec 1.1</h1></section>
<section><h1>sec 1.2</h1></section>
<section><h1>sec 1.3</h1></section>
</article>
<article><h1>art 2</h1>
<section><h1>sec 2.1</h1></section>
<section><h1>sec 2.2</h1></section>
<section><h1>sec 2.3</h1></section>
</article>
<article><h1>art 3</h1>
<section><h1>sec 3.1</h1></section>
<section><h1>sec 3.2</h1></section>
<section><h1>sec 3.3</h1></section>
</article>
</section>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)