两列表还是dl? [英] Two-column table or dl?

查看:123
本文介绍了两列表还是dl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要标记以下内容:

课程要求



日期





问题是是否使用两列元素或 dl 描述列表)元素。如果可能的话,我希望为每个特定的实例做出响应,然后通常返回一个响应。我一直无法确定这些元素,尤其是如果没有(或不需要)标题。



注意:我的问题是不是我应该如何设计这些元素。编辑:坚持HTML5草案的答案比遵守旧的HTML4建议的答案更受欢迎。


解决方案

经验法则:如果您可以在表格版本上添加标题,则应该 是一个定义列表。



另一个经验法则是:如果您可以不是在表格版本上放置标题,则应该是定义列表。

这是因为一个好的列表应该不会成为表格,反之亦然。下面是一个很好的定义列表的例子:



身高

180cm

体重

180kg

电话

555-5555

123- 4567



当我们尝试将其转换为表格时,我们得到...

 
术语释义
------------------------
身高180cm
体重180kg
电话555 -5555
123-4567

查看列标题;它只是术语和定义!



身高,体重和电话是完全不同的东西,完全不同的定义与它们相连。 555-5555和180cm属于同一列吗?它是没有意义的!



然而,有时你会看到像这样的表

 
高度| 180cm
重量| 180kg
电话| 555-5555
| 123-4567

没有术语和定义作为标题,单元格的标题被认为是在第一列。恕我直言,当你有一个像你使用表格错误的表格,而应该使用定义列表。要使表格合理,它必须有多行,每行的每个单元格可以通过其列标题来定义。



类似这样的例子:

 
名称身高体重
------------------------
约翰180cm 180kg
杰克170cm 155kg

约翰和杰克是名字。 180厘米和170厘米是高度。重量180kg和155kg。你有一个单元格与行和列的重要关系,并且你不能把它放在一个定义列表中,而不会切断那个重要的关系。因此,在这种情况下应该使用一个表。



TL; DR:
问题中的两列表可以有标题。所以它应该是一个表。



请参阅:

 
类必需点数
---------------------------------------------
队列教学10点。
队列研究和报告20点。


I have the following content I need to mark up:

Course requirements:

and dates:

The question is whether to use a two-column table element or a dl (description list) element. I would like a response for each specific instance, and then a response in general if possible. I've always had trouble deciding on these elements, especially if the table doesn't have (or need) headers.

Note: My question is not how I should style these elements. I'll get to the presentation after I decide on the semantics.

EDIT: Answers that adhere to the HTML5 draft are favored over answers that adhere to the old HTML4 recommendation.

解决方案

Rule of thumb: if you can put a header on the table version, it should not be a definition list.

Another rule of thumb: If you can not put a header on the table version, it should be a definition list.

That's because a good list should make no sense as a table and vice-versa. Here's an example of what a good definition list looks like:

Height
180cm
Weight
180kg
Telephone
555-5555
123-4567

When we try to convert this to a table we get...

Terms         Definitions
------------------------
Height        180cm 
Weight        180kg 
Telephones    555-5555 
              123-4567

Look at the column headers; it's just "terms" and "definitions"!

Height, weight and telephone are completely different things with completely different definitions attached to them. Where in the world do 555-5555 and 180cm belong in the same column? It makes no sense!

However, sometimes you see tables like this

Height        |    180cm 
Weight        |    180kg 
Telephones    |    555-5555 
              |    123-4567

There are no terms and definitions as header, the headers of the cells are assumed to be on the first column. IMHO when you have a table like that you are using tables wrong and you should use a definition list instead. For a table to be justifiable it must have multiple rows and each cell of each row can be defined by its column's headers.

Something like this for example:

Name    Height    Weight
------------------------
John    180cm     180kg
Jack    170cm     155kg 

John and Jack are names. 180cm and 170cm are heights. 180kg and 155kg are weights. You have an important relationship of cells with their rows and columns, and you can't put this in a definition list without severing that important relationship. So in this case a table should be used.

TL;DR: The two column table in your question can have headers. So it should be a table.

See:

Class                         Required Points
---------------------------------------------
Cohort Teaching               10 pts.
Cohort Research and Report    20 pts.

这篇关于两列表还是dl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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