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.
<col>: The Table Column element. The <col> HTML element defines a column within a table and is used for defining common semantics on all common cells. It is generally found within a <colgroup> element.
Definition and Usage The <tr> element defines a table row, the <th> element defines a table header, and the <td> element defines a table cell. An HTML table may also include <caption>, <colgroup>, <thead>, <tfoot>, and <tbody> elements.
Definition and UsageThe <dl> tag defines a description list. The <dl> tag is used in conjunction with <dt> (defines terms/names) and <dd> (describes each term/name).
HTML Tables are sets of data that are presented in rows and columns. To make an HTML table use the <table> element. You can use <tr> to create rows, <td> to create columns, and <th> to create table headers.
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.
The table element would best suit your needs, in terms of semantics.
W3C states that the table
element "allows authors to arrange data -- text, preformatted text, images, links, forms, form fields, other tables, etc. -- into rows and columns of cells", which is exactly how you formatted your example.
The W3C states that the dl
tag is for lists that "consist of two parts: a term and a description". Since "10 pts." is not the description of the term "Cohort Teaching", this is not the proper element to use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With