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
359 views
in Technique[技术] by (71.8m points)

html - Which semantics is better for a list of articles?

I was asking myself for the markup of a list of entries of a blog.

Which could be like that:

Case 1 :

<article>...</article>
<article>...</article>
<article>...</article>

or case 2 :

 <ol reversed>
    <li><article>...</article></li>
    <li><article>...</article></li>
    <li><article>...</article></li>
 </ol>

The example seems to be logic: "it's a list of entries order by desc date"

An other example is a list of important step to use a product:

<ol>
     <li><section><h1>step 1</h1></section></li>
     <li><section><h1>step 2</h1></section></li>
     <li><section><h1>step 3</h1></section></li>
</ol>

To get an outline like:

product name
    description
    how to use
       step 1
       step 2
       step 3
    customer reviews
    etc

Do you think it’s too much markup for this content?

My purpose is to get a best HTML5 syntax and outline, but I don’t want to fill the HTML with useless tags.

EDIT: The real question isn’t what is better but it’s more something like to know what developers are thinking about this different ways. Because there are a lot of ways to do things, but sometimes if 2 ways are correct there is maybe a more "logical" or "relevant" method to do it.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

ol must only be used if "changing the order would change the meaning". Just because content is sorted somehow doesn’t necessarily mean that ol is appropriate.

If you should use a list (whether ol or ul) depends on your actual content and its context, it can’t be answered generally. The HTML5 spec defines these lists as "list of items", without specifying what a list is or what qualifies as item.

A possible/subjective rule of thumb (with many exceptions): Look at your content and ask yourself if you would call it a list, and if you could picture it with typical bullet points.

A page, titled "Blog", showing 10 fulltext blog posts? Probably not.
A sidebar, titled "Related posts", showing 10 links to blog posts? Probably yes.

This suggests that the "complexity" of content might play a role, too, so another possible/subjective rule of thumb (with even more exceptions): If an item has a heading (i.e., it’s a section) and long content, you might not need a list.

Steps to use a product, where each step consists of long explanations with images? Probably not.
Steps to use a product, where each step consists of a short sentence? Probably yes.


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

...