我目前正在从事一个电子商务项目,不知道是使用文章、部分还是 div 来包装产品列表。
它后面有多个部分用于诸如促销之类的内容,我不想使用 div,因为以下部分将具有更大的意义并破坏它,但是它应该比以下部分具有更大的意义。
我正在考虑文章标签,但找不到在博客之外使用它的示例。我注意到人们认为它可以接受单个项目(产品页面),但是应该使用什么方法来浏览产品列表?
最佳答案
section
specification很有指导意义:
The
section
element represents a generic document or application section. A section, in this context, is a thematic grouping of content, typically with a heading, possibly with a footer.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 thediv
element instead.
如果许多元素在主题上相关并且可以在一个共同的标题下组合在一起(例如“鞋子”),那么将产品包装在 section
中.
如果您包装的元素不相关,不能归为一个共同的标题,并且只是为了样式而包装,那么请使用 div
.
为了完整起见, article
标签代表(来自同一页面):
a self-contained composition in a document, page, application, or site and that is, in principle, independently distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.
因此您的每件待售元素都是 article
在 section
内.
作为最后的旁注,我不会将整个页面包装在 <div role="main">
中。 : 标题肯定位于主要内容的外部。
关于html - 产品列表的文章、部分或 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9718490/