这是使用 <section>
的正确方法吗?标签?
<section id="container">
<section id="outer">
<section id="inner">
</section>
</section>
</section>
我正在考虑是否应该只使用一个部分 ID,而将其他两个部分保留为 div?
最佳答案
如果您只是使用这些元素将事物放置在某个位置/样式事物,那么您可能应该使用 div。
部分实际上是用于将属于一起的内容分组 - 你真的不应该有一个没有标题(H1 或类似)元素的部分来描述该部分包含的内容......我认为过去有几个人犯过类似的错误:
http://html5doctor.com/the-section-element/
来自规范:
NOTE: The section element is not a generic container element. When an element is needed for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead. A general rule is that the section element is appropriate only if the element's contents would be listed explicitly in the document's outline.
话虽如此,嵌套节元素是完全可以接受的。也许是这样的:
<section>
<h1>Portishead</h1>
<p>Portishead are a cool band from Bristol</p>
<section>
<h1>Dummy (album)</h1>
<p>some info....</p>
<img src="..." />
</section>
<section>
<h1>Portishead (album)</h1>
<p>some other info info....</p>
<img src="..." />
</section>
</section>
关于html - 嵌套 HTML5 部分标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7041283/