我有一个由各种“部分”组成的页面,如视频、新闻提要等。我对如何用 HTML5 表示这些感到有点困惑。目前我将它们作为 HTML5 <section>
s,但经过进一步检查,它们看起来更正确的标签是 <article>
.任何人都可以为我阐明这一点吗?
这些东西都不是真正意义上的博客文章或“文档”,因此很难看出要应用哪个元素。
干杯
编辑:我选择使用 article
标签,因为它似乎是不相关元素的容器标签,我猜我的“部分”是。然而,实际的标签名文章似乎相当具有误导性,尽管他们说 HTML5 的开发更多地考虑了 Web 应用程序,但我发现很多标签更以博客为中心/基于文档。
无论如何,感谢您的回答,它看起来相当主观。
最佳答案
在W3 wiki page about structuring HTML5 ,它说:
<section>
: Used to either group different articles into different purposes or subjects, or to define the different sections of a single article.
然后显示an image我清理的:
它还描述了如何使用 <article>
标签(来自上面相同的 W3 链接):
<article>
is related to<section>
, but is distinctly different. Whereas<section>
is for grouping distinct sections of content or functionality,<article>
is for containing related individual standalone pieces of content, such as individual blog posts, videos, images or news items. Think of it this way - if you have a number of items of content, each of which would be suitable for reading on their own, and would make sense to syndicate as separate items in an RSS feed, then<article>
is suitable for marking them up.In our example,
<section id="main">
contains blog entries. Each blog entry would be suitable for syndicating as an item in an RSS feed, and would make sense when read on its own, out of context, therefore<article>
is perfect for them:
<section id="main">
<article>
<!-- first blog post -->
</article>
<article>
<!-- second blog post -->
</article>
<article>
<!-- third blog post -->
</article>
</section>
Simple huh? Be aware though that you can also nest sections inside articles, where it makes sense to do so. For example, if each one of these blog posts has a consistent structure of distinct sections, then you could put sections inside your articles as well. It could look something like this:
<article>
<section id="introduction">
</section>
<section id="content">
</section>
<section id="summary">
</section>
</article>
关于html - 章节与文章 HTML5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7549561/