A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

Is the design of <dl> tag flawed?

IanY
2016-11-24

The design of <dl> tag is possibly flawed. Here are two points that describe the possible flaw:

  • dl designed to be independent of ul and ol implies that dl is neither unordered nor ordered.
  • The spec for dl does not provide a method for defining whether a dl is unordered/ordered. Even if it does, the purpose of the method would overlap with the purposes of ul and ol.

Wouldn’t it make more sense that <dt> and <dd> tags be in ul and ol elements instead so that when we want to write an unordered and an ordered description lists, we would write the following two pieces of code?

<ul>
    <li>
        <dt></dt>
        <dd></dd>
    </li>
    <li>
        <dt></dt>
        <dd></dd>
    </li>
    <li>
        <dt></dt>
        <dd></dd>
    </li>
</ul>
<ol>
    <li>
        <dt></dt>
        <dd></dd>
    </li>
    <li>
        <dt></dt>
        <dd></dd>
    </li>
    <li>
        <dt></dt>
        <dd></dd>
    </li>
</ol>
MT
2016-11-24

While the idea itself probably makes some sense, the only difference between ordered and unordered lists in practice is that ordered-list items have indices instead of bullets in visual browsers. Both UL and OL in fact have a certain order — document order.

mkay581
2016-11-25

Hmm. I have always assumed that the order of <dl>s are ambiguous because they don’t require a visual representation of the order, unlike <ul>s and <ol>s. What does the developer gain from having <dt>s and <dd>s be declared “unordered” or “ordered” in markup?

IanY
2016-11-25

List type is also read in screen readers. Could you please clarify the “document order” in the last sentence? I thought the order of the items in ul is not important.

IanY
2016-11-25

Developers probably do not gain from having <dt>s and <dd>s be declared “unordered” or “ordered” in markup. The benefit is mainly for users, both visual users and AT users.

mkay581
2016-11-25

What is this benefit? With <dl>s, users already know they are experiencing a definition list. What is the benefit of user knowing that a definition list is unordered/ordered?

IanY
2016-11-25

The benefit of users knowing that a description list is unordered/ordered is simply they know that a description list is unordered/ordered.

There are description lists in which order matters, and there are also description lists in which order does not matter. Currently, there is no way to convey that to users.

mkay581
2016-11-25

Can you give a use-case of when the order of a definition list matters? AFAIK, definition lists are built as key-value pairs where the order would never matter. If the developer cares that much about the order of a definition list, they can always just insert the list items in the desired order directly in the HTML markup. AT technology will read it in whatever order the elements appear in the DOM.

IanY
2016-11-25

To name a few, the workflow of a project, the life cycle of a creature, the production of a product. Things like those undergo several stages whose orders matter and should not change.

If just insertting the list items in the desired order when the order matters would be enough, we wouldn’t need two different types of list (ul and ol) to address ordering.

FYI, the meaning of dl has been changed to “description list”; it is not “definition list” anymore.

mkay581
2016-11-25

<ul> and <ol> are necessary to visually show to the user either bullet points (for <ul>) and numbers (for <ol>) to the left of their contents. <dl> does not have that–I believe this is exactly what @MT was illustrating when he said the following:

I’ll leave this up to the rest of the group to discuss this further with you but you still haven’t yet described a large enough benefit of why <dl> isn’t sufficient for its uses or “flawed”, as you say.

IanY
2016-11-25

And the point to show either bullets or numbers to users is to let users know whether the order matters or not, right? <dl> does not have that so there is no method to define whether a <dl> is unordered/ordered, and that has been described in my original post.

Those points have been described in my original post.

MT
2016-11-25

Document order is how elements (and nodes in general) are ordered relative to each other in the document/DOM.

Item order may be not important, but it always exists because HTML document is not a database, and characters and elements it consists of always have certain order.

You are probably right that there is some semantics in whether exact item order in a specific list is important, I just doubt such semantics is essential in HTML:

AT naturally read document contents in document order, while lists in HTML documents are unlikely used as a source of data for conventional databases where having or not having specific item order could really matter.

IanY
2016-11-26

@MT I see. So “document order” means the order of elements in a HTML document. That’s a different topic though.

zcorpan
2016-11-30

You can indicate to the reader whether the order is important or not using surrounding text, or in some cases it is clear from context.

IanY
2016-12-01

Thanks for your input. But if we could just rely on surrounding text or context for addressing ordering, we wouldn’t have to introduce two different types of list (ul and ol).

zcorpan
2016-12-01

They were introduced when HTML was first invented. We are not designing a new language from scratch here. Introducing a new element has a cost that needs to be weighed against the benefit. “Wouldn’t it make sense…”, on its own, is not enough to make a change.

Those lists also have distinct default rendering, numbers vs. bullets. dl doesn’t have those currently and I am not aware of any examples where CSS is used to add bullets or numbers to dl, which suggests to me that it is not a desired rendering.

IanY
2016-12-01

@zcorpan This thread does not suggest any new element. And as described before, the design of dl currently made users unable to know whether a description list is unordered/ordered so it isn’t just a thing of “Wouldn’t it make sense…”

IMHO, when a rendering is beneficial to users, it is a desired rendering. Making <dt> and <dd> inside ul and ol allows bullets and numbers to inform users whether a description list is unordered/ordered. In that case, bullets and numbers would be desired renderings.

Garbee
2016-12-01

You could implement numbering/bullets using CSS if you feel it is that important to your users to have that kind of display.

IanY
2016-12-01

@Garbee ATs are unable to read list styles set by CSS.

Garbee
2016-12-01

Can you provide an actual case where this is beneficial? Typically, ol and ul are targeting a different use-case than dl. So far it is just “feeling” it could be better but no real case is provided. Very few people want to put effort into changing such long-standing things on the technical side unless there is a real benefit somewhere. So far, no benefit is provided simply suggested. It needs to be remembered that eventually even if the spec does change based on a suggestion we still need to encourage browser vendors to implement the change. None will without a specific set of cases where the change provides a benefit that is otherwise not achievable (or very difficult) with the existing landscape.