Christian Heilmann

Keeping it on the < dl > – another HTML gem you never use

Friday, April 18th, 2025 at 11:19 am

In a moment of boredom, I wrote a little app/web page that shows lovely words we should be using more. It is done in plain HTML, JavaScript, and some CSS. The source code is available, and I am also happy to receive pull requests adding more lovely words.

screenshot of the application showing the lovely word Cattywampus

This is not what I wanted to talk about today. Instead, I wanted to talk about a thing I used that I don’t see being used in the wild enough: Description Lists. Never heard of them? You are not alone…

One in 10 Americans think HTML is a sexually transmitted disease

HTML, as you may remember, is not about adding look and feel to a document, but about giving it structure. A definition list is the right thing to use when you have a list of terms and definitions. This is a pretty common thing on the web, and yet I hardly ever see any in use. The first time I came across a description list was in the bookmarks.htm file of Netscape. Here is how description lists are defined:

<dl>
  <dt>HTML</dt>
  <dd>Hypertext Markup Language - a language to describe content on the web.</dd>
</dl>

Without any CSS they render as terms on lines with a break and descriptions with an indent.

It may be that people don’t know about or don’t use description lists as they have a syntax that is different from other lists. Both unordered (UL) and ordered (OL) lists are parent elements to one or more list item (LI) elements. Description lists are different. The DL element is the direct parent to both the term (DT) and the description element (DD), and there can be more than one of each. Some terms have more than one description, and one description may apply to various terms. MDN has some great demos:

<dl>
  <dt>Firefox</dt>
  <dt>Mozilla Firefox</dt>
  <dt>Fx</dt>
  <dd>
    A free, open source, cross-platform, graphical web browser developed by the
    Mozilla Corporation and hundreds of volunteers.
  </dd>
 
  <!-- Other terms and descriptions -->
</dl>

<dl>
  <dt>Firefox</dt>
  <dd>
    A free, open source, cross-platform, graphical web browser developed by the
    Mozilla Corporation and hundreds of volunteers.
  </dd>
  <dd>
    The Red Panda also known as the Lesser Panda, Wah, Bear Cat or Firefox, is a
    mostly herbivorous mammal, slightly larger than a domestic cat (60 cm long).
  </dd>
 
  <!-- Other terms and descriptions -->
</dl>

The practical upshot of using description lists is that you have baked-in accessibility. Both the term and the description get announced as roles to assistive technology. You can spot-check that using the element picker in the browser developer tools.

The browser developer tools element picker showing that a dt element has a role of term

The browser developer tools element picker showing that a dd element has a role of definition

Another excellent example on MDN is that you can use description lists to describe metadata as a list of key-value pairs:

<dl>
  <dt>Name</dt>
  <dd>Godzilla</dd>
  <dt>Born</dt>
  <dd>1952</dd>
  <dt>Birthplace</dt>
  <dd>Japan</dd>
  <dt>Color</dt>
  <dd>Green</dd>
</dl>

So, next time you have a list of items you want to describe, why not reach deeper into the HTML treasure chest and use a description list?

Share on Mastodon (needs instance)

Share on Twitter

Newsletter

Check out the Dev Digest Newsletter I write every week for WeAreDevelopers. Latest issues:

160: Graphs and RAGs explained and VS Code extension hacks Graphs and RAG explained, how AI is reshaping UI and work, how to efficiently use Cursor, VS Code extensions security issues.
159: AI pipelines, 10x faster TypeScript, How to interview How to use LLMs to help you write code and how much electricity does that use? Is your API secure? 10x faster TypeScript thanks to Go!
158: 🕹️ Super Mario AI 🔑 API keys in LLMs 🤙🏾 Vibe Coding Why is AI playing Super Mario? How is hallucinating the least of our worries and what are rules for developing Safety Critical Code?
157: CUDA in Python, Gemini Code Assist and back-dooring LLMs We met with a CUDA expert from NVIDIA about the future of hardware, we look at how AI fails and how to play pong on 140 browser tabs.
156: Enterprise dead, all about Bluesky and React moves on! Learn about Bluesky as a platform, how to build a React App and how to speed up SQL. And play an impossible game in the browser.

My other work: