Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
384 views
in Technique[技术] by (71.8m points)

html - 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?

Every product list contains 1 main image, name and price.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

From how you describe the product listing (image + name + price), it doesn't seem to fit the description of an article in HTML5:

The article element represents a section of content that forms an independent part of a document or site; 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.

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)
  • AliBaba and Ebay just uses div boxes without any type of list.
  • Taobao uses a combination of both (div for the box, and ul for the name and price)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...