- From: Jim Dabell <jim-www-html@jimdabell.com>
- Date: Tue, 11 Mar 2003 16:38:16 +0000
- To: www-html@w3.org
On Monday 10 March 2003 10:25 pm, Graph Dept. wrote: > I was wondering what is the general consensus for display Key/Item pairs > (or "name/value") in (X)HTML? > e.g. > Name: T. Daniel > Occupation: Web Developer > Favorite Ice Cream: chocolate > > I've heard some say this is a good use for tables, some say that <dl> is > better for something like this. I could argue either way, I just wanted to > gather some more opinions. I would say that a <dl> element would not be appropriate for this data, since it doesn't appear to be a list of definitions. For instance, I'd consider this to be a suitable use of <dl>: <dl> <dt>Name</dt> <dd>A label identifying a particular entity.</dd> </dl> The definition of "name" is not "T. Daniel", nor is the opposite true. I would possibly mark up the example you gave as follows: <table> <caption>Personal Information</caption> <tr> <th scope="row">Name</th> <td>T. Daniel</td> </tr> <tr> <th scope="row">Occupation</th> <td>Web Developer</td> </tr> <tr> <th scope="row">Favourite Icecream</th> <td>Chocolate</td> </tr> </table> The definition of the <dl> element seems to agree with me: http://www.w3.org/TR/html401/struct/lists.html#edef-DL ...until this bit: "Another application of DL, for example, is for marking up dialogues, with each DT naming a speaker, and each DD containing his or her words." ...which seems completely wrong to me, and at odds with both the name of the element, and its description up until that point. A lot of people seem to like treating <dl> as a generic key/value container, and this example would seem to support that use. So, to address your original question, I believe that, although the recommendation seems to condone using <dl> in this way, I would use a <table> element. I may be in a minority though. -- Jim Dabell
Received on Tuesday, 11 March 2003 11:41:44 UTC