是的,您可以在那里使用section
。
当您使用标题时,you have "implicit" sections anyway。通过使用section
,您可以使其明确,即encouraged(请参见最后一个报价)。
这些片段语义上等同(它们具有相同的outline):
<!-- using headings + div elements -->
<aside class="example-1">
<h1>Heading for this aside</h1>
<div>
<h2>Latest news</h2>
<p>…</p>
</div>
<div>
<h2>Choose site theme</h2>
<p>…</p>
</div>
</aside>
<!-- using headings only -->
<aside class="example-2">
<h1>Heading for this aside</h1>
<h2>Latest news</h2>
<p>…</p>
<h2>Choose site theme</h2>
<p>…</p>
</aside>
<!-- using section elements -->
<aside class="example-3">
<h1>Heading for this aside</h1>
<section>
<h2>Latest news</h2>
<p>…</p>
</section>
<section>
<h2>Choose site theme</h2>
<p>…</p>
</section>
</aside>
注意:如果你不提供的aside
标题,文档大纲将是不同的,当section
用来。这不是一件坏事;无论如何,我想这个轮廓是你通常想要的。你可以玩gnnedders'online outliner。
当然还可以有其它切片元件代替section
的aside
内(例如nav
为该aside
,或article
的相关帖子的列表导航等)。
注意:就你而言,你可能会考虑使用几个aside
元素来代替。这一般不能被回答,它取决于内容,但一个经验法则可能是:如果所有这些部分都以某种方式相关(如果你能找到一个标题描述的话),在里面使用一个aside
和几个sections
/标题所有这些部分)。如果不是,请使用几个aside
。
所以,你的例子可能看起来像:
<aside class="widget">
<h2>Latest news</h2>
<ul>…</ul>
<a>more news</a>
</aside>
<aside class="widget">
<h2>Choose site theme</h2>
<input type="select" />
</aside>
<aside class="widget">
<h2>Newsletter subscription</h2>
<form>…</form>
</aside>
<aside class="widget">
<h2>Related articles</h2>
<ul>…</ul>
</aside>
(并使用一个容器div
这些,如果你需要一个。)的
“‘节’一边是绝对不会在属于什么整个文件的大纲“。为什么不? '
“绝对不属于大纲”:因为使用了标题('h2'),所以即使没有使用'section'元素,大纲中也会列出“小”节。我认为这非常重要:最新消息,新闻订阅等*应该是大纲条目。 – unor
我想这一切都取决于“搁置”内容的真实性。我会使用旁边的小块内容来真正注释内容,而不是文档整体结构的一部分。我不认为把某些顶层构造提升到旁边有什么问题,但对我来说这似乎很奇怪。 #恕我直言 –