哪些语义对文章列表更好? [英] Which semantics is better for a list of articles?

查看:105
本文介绍了哪些语义对文章列表更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这可能是这样的:



案例1:

 < article> ...< / article> 
<文章> ...< /文章>
<文章> ...< /文章>

或案例2:

 < ol颠倒> 
< li>< article> ...< / article>< / li>
< li>< article> ...< / article>< / li>
< li>< article> ...< / article>< / li>
< / ol>

这个例子似乎是逻辑的:它是按排日期排序的条目列表



另一个例子是使用产品的重要步骤:

  <醇> 
< section>< h1>步骤1< / h1>< / section>< / li>
< section>< h1>步骤2< / h1>< / section>< / li>
< section>< h1>步骤3< / h1>< / section>< / li>
< / ol>

获得一个大纲:

 产品名称
描述
如何使用
步骤1
步骤2
步骤3
顾客评论

你认为这个内容的标记太多吗?



我的目的是获得最好的HTML5语法和大纲,但我不想用无用的标记填充HTML。



编辑:真正的问题不是什么更好,而是更像是知道开发人员正在考虑这些不同的方式。因为有很多方法可以做到这一点,但有时候如果有两种方法是正确的,那么可能需要更合理或相关的方法来完成它。

解决方案

ol 。仅仅因为内容被排序并不一定意味着 ol 是合适的。



如果您应该使用一个列表(无论是 ol 还是 ul )取决于您的实际内容及其上下文,它可以一般都不会回答。 HTML5规范将这些列表定义为项目列表,而不指定列表是什么或什么符合

一个可能的/主观的经验法则(有很多例外):看看你的内容,问自己你是否称它为一个列表,如果你可以用典型的要点。



一个名为博客的页面,显示了10篇全文博客文章?可能不会。

标题为相关帖子的侧栏,显示10篇博客帖子的链接?可能是的。

这表明内容的复杂性也可能起作用,所以另一个可能的/主观的经验法则(甚至更多的例外):If一个项目有一个标题(即它是一个部分)和长的内容,你可能不需要一个列表。



使用产品的步骤,其中每个步骤由长与图像的解释?可能不会。

使用产品的步骤,每一步都包含一个简短的句子?可能是。




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.

解决方案

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.

这篇关于哪些语义对文章列表更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆