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.
Best Answer
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...
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
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:
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: