DEV Community

Robert Mion
Robert Mion

Posted on

HTML has three list types: OL, UL, and...?

DL

The 'D' stands for description.
I prefer to refer to it as definition.

How to use it

<dl>
  <dt>Term you seek to describe or define</dt>
  <dd>First of one or more descriptions or definitions</dd>
  <dd>Optional second of many descriptions for the same term</dd>
  <dd>So on and so forth...</dd>
</dl>
Enter fullscreen mode Exit fullscreen mode

Common structure

<dl>
  <dt>Term</dt>
  <dd>Description</dd>
  <dt>Term</dt>
  <dd>Description</dd>
</dl>
Enter fullscreen mode Exit fullscreen mode

What I hear you saying

I'd like to layout each term-description pairing as a group. How might I do that?

Secret trick: enclose each pair in a <div>

<dl>
  <div>
    <dt>Term</dt>
    <dd>Description</dd>
  </div>
  <div>
    <dt>Term</dt>
    <dd>Description</dd>
  </div>
</dl>
Enter fullscreen mode Exit fullscreen mode

Your challenge

Find

  • Look through some of your code
  • Find examples that fit this structure: term with descriptions
  • Re-factor your code...

And replace

  • Using <div>s or <span>s? Upgrade to a <dl>.
  • Using a heading or paragraph with <ul>s or <ol>s? Upgrade to a <dl>.

Learn something today? Keep up the habit with a fun game I made:

Fix a function! - 5 daily exercises to help you practice HTML, CSS and JavaScript

Top comments (1)

Collapse
 
shayanypn profile image
shayan

Really useful, I barely use

tag, but it has great use