In this section, we will learn what description lists are and how we can create them in HTML.
Description List in HTML
The description list is a type of list with items and a description for each item on the list!
In HTML, we use <dl> element to create such type of lists.
Here’s the syntax of this element:
<dl> <dt> term </dt> <dd> description</dd> </dl>
The <dl> element itself is just the container for the description list! But, in order to create each item and its description, we need two more HTML elements!
These elements are: <dt> and <dd>
The <dt> element defines the term or the item that we want to set a description for it.
The <dd> element, on the other hand, is used to create the definition or description of the related item.
Alright, let’s run an example as see the use of these 3 elements in practice then.
Example: creating Description Lists in HTML
See the Pen creating Description Lists in HTML by Omid Dehghan (@odchan1) on CodePen.
Note that with each <dt> element, we immediately use a <dd> element to add the description for that item created by the <dt> element.