简体   繁体   English

产品列表应该使用“li”还是“article”?

[英]Should I use 'li' or 'article' for products listing?

I made some research and didn't find an appropriate answer.我做了一些研究,但没有找到合适的答案。 I'm wondering if it's better to keep using li elements for a products listing or maybe switch to the article element?我想知道是继续为产品列表使用li元素还是切换到article元素更好?

Every product list contains 1 main image, name and price.每个产品列表包含 1 个主要图像、名称和价格。

From how you describe the product listing (image + name + price), it doesn't seem to fit the description of an article in HTML5 : 从描述产品清单(图像+名称+价格)的方式来看,它似乎不适合HTML5中的文章描述:

The article element represents a section of content that forms an independent part of a document or site; article元素代表内容的一部分,形成文档或网站的独立部分; for example, a magazine or newspaper article, or a blog entry. 例如,杂志或报纸上的文章,或博客条目。

Ask yourself: Will that content be independent from the rest of the page content? 问问自己:该内容是否与页面其余内容无关? If you take it out of context, will it make sense by itself? 如果您脱离上下文考虑它本身是否有意义? If the answer is "No", then you should consider that an <article> may not be the most suitable tag. 如果答案为“否”,那么您应该考虑<article>可能不是最合适的标签。

If you have multiple products to display, a styled list (ordered or unordered) seems like the best approach for this. 如果要显示多个产品,则样式列表(有序或无序)似乎是实现此目的的最佳方法。 But check some practical cases: how do big companies do it?: 但是检查一些实际情况:大公司如何做到这一点?:

  • Amazon, Google Shopping, TMall, and Walmart use lists ( ol or ul ) Amazon,Google Shopping,TMall和Walmart使用列表( olul
  • AliBaba and Ebay just uses div boxes without any type of list. AliBaba和Ebay仅使用div框而没有任何类型的列表。
  • Taobao uses a combination of both ( div for the box, and ul for the name and price) 淘宝使用了两者的组合( div表示框, ul表示名称和价格)

This is not a question of either/or. 这不是一个/或一个问题。

If using ul is appropriate has nothing to do with using article or not; 如果使用ul是合适的,则与使用article无关。 and if using article is appropriate has nothing to do with using ul or not. 并且是否使用article合适与是否使用ul没有关系。

If each product's content matches the definition of the article element , you should use it. 如果每个产品的内容都与article元素的定义匹配,则应使用它。

If the list of products matches the definition of the ul element , you should use it. 如果产品列表与ul元素的定义匹配,则应使用它。

Generally speaking, a typical web shop listing some products (or product teasers), with some content/metadata about the product, should use an article for each product. 一般来说,一个典型的网上商店上市的一些产品(或产品的玩笑),提供有关产品的一些内容/元数据,应该使用一个article为每个产品。 If ul should be used is more opinion-based . 如果应使用ul更多基于意见

只需保留li元素,并从http://schema.org添加product schema以进行语义标记

If you read the developer.mozilla documentation about it, it says:如果您阅读有关它的developer.mozilla文档,它会说:

The HTML element represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable (eg, in syndication). HTML 元素表示文档、页面、应用程序或站点中的自包含组合,旨在独立分发或重用(例如,在联合中)。 Examples include: a forum post, a magazine or newspaper article, or a blog entry, a product card , a user-submitted comment, an interactive widget or gadget, or any other independent item of content.示例包括:论坛帖子、杂志或报纸文章、博客条目、产品卡片、用户提交的评论、交互式小部件或小工具,或任何其他独立的内容项。

So a product card should be in an article tag.所以产品卡片应该在文章标签中。

我应该使用<section> ,<div> 或者<article>这里? 我不想染上“div”流感</article></div><div id="text_translate"><p>我开始学习语义 HTML,我有点困惑。 我已经阅读了很多关于这些标签的内容,但我仍然不知道该使用哪一个。 我正在创建个人作品集,这是登录页面的一部分:</p><pre> &lt;section&gt; &lt;div&gt; &lt;h2&gt;Who am I?&lt;/h2&gt; &lt;p&gt;I'm &lt;b&gt;Nolan Knefati&lt;/b&gt;, Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla voluptatibus distinctio quisquam, adipisci officia necessitatibus iusto, Tempore quos a illum, perspiciatis fugiat expedita consequuntur maxime voluptate reprehenderit beatae. explicabo iure?.&lt;/p&gt; &lt;/div&gt; &lt;div&gt; &lt;h2&gt;What sort of services do I offer,&lt;/h2&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit, Quia voluptas totam. minima eaque eveniet eos distinctio labore fugit dolorem. vel molestiae laudantium unde deserunt voluptatem reprehenderit aliquid repellat rem hic,&lt;/p&gt; &lt;/div&gt; &lt;div&gt; &lt;h2&gt;Some projects I have worked on&lt;/h2&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit, Voluptatem earum veniam quas? debitis neque molestias perferendis eius. beatae nobis enim corrupti dolor non eligendi magni tempore fugiat quibusdam itaque delectus?&lt;/p&gt; &lt;/div&gt; &lt;a href="contact.html" class="standardbutton"&gt;I want to hire you&lt;/a&gt; &lt;/section&gt;</pre><p> 我确实想避免感染“div”流感,这就是为什么我想看看如何在语义上更好地写这个。</p><hr><p> 这就是代码遵循所有提示的方式。</p><pre> &lt;main&gt; &lt;h1&gt;Welcome, I'm Nolan.&lt;/h1&gt; &lt;img src="Media/Ferret.jpg" alt="A ferret enjoying the snow, also looking at you" class="presentationpicture" title="Most recent Nolan's portrait"&gt; &lt;section&gt; &lt;h2&gt;Who am I?&lt;/h2&gt; &lt;p&gt;I'm &lt;b&gt;Nolan Knefati&lt;/b&gt;, Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla voluptatibus distinctio quisquam, adipisci officia necessitatibus iusto, Tempore quos a illum, perspiciatis fugiat expedita consequuntur maxime voluptate reprehenderit beatae. explicabo iure?&lt;/p&gt; &lt;/section&gt; &lt;section&gt; &lt;h2&gt;What sort of services do I offer.&lt;/h2&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit, Quia voluptas totam, minima eaque eveniet eos distinctio labore fugit dolorem. vel molestiae laudantium unde deserunt voluptatem reprehenderit aliquid repellat rem hic.&lt;/p&gt; &lt;/section&gt; &lt;section&gt; &lt;h2&gt;Some projects I have worked on&lt;/h2&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit, Voluptatem earum veniam quas, debitis neque molestias perferendis eius. beatae nobis enim corrupti dolor non eligendi magni tempore fugiat quibusdam itaque delectus.&lt;/p&gt; &lt;/section&gt; &lt;a href="contact.html" class="standardbutton"&gt;I want to hire you&lt;/a&gt; &lt;/main&gt;</pre><p> 我在 header 标记中拥有 H1,但我将其移动以支持主标记,因此,据了解,它在语义上会更好。</p></div></section> - Should I use <section>,<div> or <article> here? I don't want to catch the 'div' flu

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我应该使用<ol>,<ul>,<article>或<blockquote>来使用语义HTML进行评论吗? - Should I use <ol>, <ul>, <article> or <blockquote> for comments listing using semantic HTML? 我为什么要用'li'而不是'div'? - Why should I use 'li' instead of 'div'? 在HTML5中,我应该使用文章或部分标签来制作标签吗? - In HTML5 should I use article or section tags to make tabs? 为什么我应该在我的 HTML 中使用 UL/LI? - Why should I use UL/LI in my HTML? 我应该使用 <li> 以空内容作为分隔符 <ul> ? - Should I use <li> with empty content as a divider in <ul>? 什么时候应该使用 <article> 相对于 <ul> ? - When should you use <article> as opposed to <ul>? 更好用吗 <article> 要么 <li> 带有文字的图像网格标签 - Is it better to use <article> or <li> tag for image grid with text 我应该使用<section> ,<div> 或者<article>这里? 我不想染上“div”流感</article></div><div id="text_translate"><p>我开始学习语义 HTML,我有点困惑。 我已经阅读了很多关于这些标签的内容,但我仍然不知道该使用哪一个。 我正在创建个人作品集,这是登录页面的一部分:</p><pre> &lt;section&gt; &lt;div&gt; &lt;h2&gt;Who am I?&lt;/h2&gt; &lt;p&gt;I'm &lt;b&gt;Nolan Knefati&lt;/b&gt;, Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla voluptatibus distinctio quisquam, adipisci officia necessitatibus iusto, Tempore quos a illum, perspiciatis fugiat expedita consequuntur maxime voluptate reprehenderit beatae. explicabo iure?.&lt;/p&gt; &lt;/div&gt; &lt;div&gt; &lt;h2&gt;What sort of services do I offer,&lt;/h2&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit, Quia voluptas totam. minima eaque eveniet eos distinctio labore fugit dolorem. vel molestiae laudantium unde deserunt voluptatem reprehenderit aliquid repellat rem hic,&lt;/p&gt; &lt;/div&gt; &lt;div&gt; &lt;h2&gt;Some projects I have worked on&lt;/h2&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit, Voluptatem earum veniam quas? debitis neque molestias perferendis eius. beatae nobis enim corrupti dolor non eligendi magni tempore fugiat quibusdam itaque delectus?&lt;/p&gt; &lt;/div&gt; &lt;a href="contact.html" class="standardbutton"&gt;I want to hire you&lt;/a&gt; &lt;/section&gt;</pre><p> 我确实想避免感染“div”流感,这就是为什么我想看看如何在语义上更好地写这个。</p><hr><p> 这就是代码遵循所有提示的方式。</p><pre> &lt;main&gt; &lt;h1&gt;Welcome, I'm Nolan.&lt;/h1&gt; &lt;img src="Media/Ferret.jpg" alt="A ferret enjoying the snow, also looking at you" class="presentationpicture" title="Most recent Nolan's portrait"&gt; &lt;section&gt; &lt;h2&gt;Who am I?&lt;/h2&gt; &lt;p&gt;I'm &lt;b&gt;Nolan Knefati&lt;/b&gt;, Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla voluptatibus distinctio quisquam, adipisci officia necessitatibus iusto, Tempore quos a illum, perspiciatis fugiat expedita consequuntur maxime voluptate reprehenderit beatae. explicabo iure?&lt;/p&gt; &lt;/section&gt; &lt;section&gt; &lt;h2&gt;What sort of services do I offer.&lt;/h2&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit, Quia voluptas totam, minima eaque eveniet eos distinctio labore fugit dolorem. vel molestiae laudantium unde deserunt voluptatem reprehenderit aliquid repellat rem hic.&lt;/p&gt; &lt;/section&gt; &lt;section&gt; &lt;h2&gt;Some projects I have worked on&lt;/h2&gt; &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit, Voluptatem earum veniam quas, debitis neque molestias perferendis eius. beatae nobis enim corrupti dolor non eligendi magni tempore fugiat quibusdam itaque delectus.&lt;/p&gt; &lt;/section&gt; &lt;a href="contact.html" class="standardbutton"&gt;I want to hire you&lt;/a&gt; &lt;/main&gt;</pre><p> 我在 header 标记中拥有 H1,但我将其移动以支持主标记,因此,据了解,它在语义上会更好。</p></div></section> - Should I use <section>,<div> or <article> here? I don't want to catch the 'div' flu HTML5有新的标签文章,部分和旁边。我什么时候应该使用div标签? - HTML5 has new tags article, section and aside. When should I use div tag? 文章列表页面的HTML标签 - HTML tags for an article listing page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM