W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2012

[whatwg] Suggest making <dt> and <dd> valid in <ol>

From: Ian Yang <ian.html@gmail.com>
Date: Sat, 14 Jul 2012 13:22:05 +0800
Message-ID: <CAFhBhuOdNKAtTjLSyCiR++fk0LzQK_B2Lui+oUTzeB7Pn0HCXQ@mail.gmail.com>
To: whatwg@whatwg.org
Hi chief editors and everyone else,

How have you been?

Recently I was involved in a project. One of its pages has a special
content which is like a "life cycle". There are several stages in the
cycle, each stage has a term followed by some text describing the term.
Let's take the life cycle of butterfly for example:

Egg
A white egg.

Caterpillar
The egg hatches into a caterpillar. The caterpillar eats and grows a
tremendous amount.

Pupa
The caterpillar forms a hard outer shell. Inside the shell, the caterpillar
changes into a butterfly.

Butterfly
Butterflies live for only a short time. They will fly, mate, and reproduce.
The female lays an egg that was fertilized by the male.

By seeing such contents, we usually code it using definition list (<dl>).
At first, I was thinking the same idea. But then I realized that stages in
a life cycle should be regarded as ordered contents. So ordered list (<ol>)
would be more appropriate. However, if using ordered list, usually the
approach is to use general heading (<H1>) and paragraph (<p>) to wrap the
term and the description. And that loses the meaning of "definition term"
and "definition description".

I was hesitant about using definition list or ordered list. Finally, I
chose ordered list, but felt uncomfortable about that.

If we could make <dt> and <dd> being not restricted to <dl> only, but could
also exist in <ol>, the problem will be solved perfectly. Like the
following:

<ol>
    <li>
        <dt></dt>
        <dd></dd>
    </li>
    <li>
        <dt></dt>
        <dd></dd>
    </li>
    <li>
        <dt></dt>
        <dd></dd>
    </li>
</ol>


********************

And here comes another idea about the definition list (<dl>). By inspecting
the above code, <dt> and <dd>(s) could become more meaningful if they could
be grouped together by <li>. For example:

<dl>
    <li>
        <dt></dt>
        <dd></dd>
    </li>
    <li>
         <dt></dt>
         <dd></dd>
     </li>
    <li>
         <dt></dt>
         <dd></dd>
     </li>
</dl>

It's like the case of <label>s and <input>s in <form>.  Although it is
valid to just leave all <label>s and <input>s as directly children of <form>,
we often group them with <div>s (or <p>s) to make the markup more
meaningful and organized. And by doing so, we also get the side benefit of
having more styling elements.


********************

To sum up, it would be more meaningful if the following things become valid:

   - <dt> and <dd> are not restricted to <dl> only. They could also exist
   in <li> of <ol>
   - <dt> and <dd> in <dl> may, but not must, be grouped by <li> when in
   situations that using <li> to group them could make the markup more
   meaningful

And we surely don't need <dt> and <dd> in <ul> because using <dl> is more
appropriate.


Sincerely,
Ian Yang
Meaningful and semantic HTML lover  |  Front-end developer
Received on Saturday, 14 July 2012 05:22:35 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:09 GMT