December 5 2007


In his contribution to 24 ways this year, Norm has decided to tackle the issue of definition lists, or more specifically what he sees as their misuse, giving examples such as listing hardware attributes, roles and names of individuals involved in a film production and navigation elements as particular offenders:

Living by the specification, a definition list should be used for term definitions – glossaries, lexicons and dictionaries – only. Anything else is a crime against markup.

Strong words indeed. Unfortunately I think he’s quite wrong.

The root of this stems from assuming an exclusive interpretation as to what a definition list represents. The section on definition lists within the HTML specification says:

Definition lists vary only slightly from other types of lists in that list items consist of two parts: a term and a description. The term is given by the DT element and is restricted to inline content. The description is given with a DD element that contains block-level content.

Now a dictionary is an example of a collection of terms and descriptions, but it isn’t the only interpretation of this description. In essence, what the W3C specification is trying to provide is a means for semantically describing an association between something which has a title, and some sort of data. It isn’t defining the particular terms of that relationship — be it mutually exclusive, collectively exhaustive or anything else — just that there is a relationship.

What it does mandate is what is given in the Document Type Definition normative specification1, essentially stating that any number of titles can be followed by any number of data items. In fact, using the DTD normative specification’s rules, a perfectly valid document could end up being a dictionary of nonsense, since you could have any number of definition titles, none of which actually has any definition data.

One argument against misuse of definition lists stems from their use as a means of marking-up conversations, since screen readers will read each pairing of title and data as Some Name is equal to Some dialogue. Whilst I’m in agreement that this is a particularly tenuous use of definition lists, it is entirely the fault of screen reader software if it interprets it this way. Nowhere in the specification is it asserted that a definition title equates to a particular piece of definition data (in fact, how could it ever be, if you can have multiple or even no definitions?).

It’s also wrong to say that where a given definition has multiple descriptions (or multiple terms are defined by a single description) they “should be rolled up”. This isn’t stated in the HTML specification, and given that it’s generally true that the order in which elements appear on a page has semantic importance, it’s a very bad idea to assume that you can arbitrarily change that order. If the only purpose behind definition lists was to represent dictionaries then changing their order in this way wouldn’t necessarily be harmful, but since they’re used in many other contexts, this is an unsafe assumption.

So what is the real problem here? I would posit that the issue is really that in HTML 4, definition lists are ambiguous and open to a multitude of interpretations. Some of these are weaker than others, as the WHATWG clearly agrees by drafting the new dialog element to more semantically mark-up conversations. Norm notes that they have chosen not to create any other new elements to serve some of the various purposes definition lists are used for, but I would interpret this as simply meaning they are currently fit for (most) purposes.

  1. As has been pointed out to me, what I really mean here is the normative specification text; the specific terminology of these details interests me very little, so it was inevitable I’d get it wrong.