Definition Lists

We looked earlier at how to set up ordered lists and unordered lists. There is a third type of list supported by (X)HTML that works a little differently from the other two because it allows for two different types of entries within the list. The original concept for this type of list was to provide a way to list terms and the definitions of those terms and so this tyle of list is usually called a definition list and the two typed of entries are referred to as terms and descriptions. This gives us the three tags that are used to create such a list.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Headings</title>
</head><body>
<dl>
<dt>
Term One</dt>
<dd>
This is the definition for term one</dd>
<dt>Term Two</dt>
<dd>This is the definition for term two</dd>
</dl>

</body></html>

Here's what the definition list page looks like in your web browser.

In this particular instance we have used the definition list to actually specify terms and their definitions but this type of list can also be useful for any sort of list that has two types of information to be presented. While the example shows the terms and definitions alternating within the list a definition list does not require these entries to alternate and so you can have multiple terms following one another without definitions or multiple definitions following one another without terms if what you are usinng the list for requires it.

Another thing to note about using a definition list is that while the default layout in most browsers is to display the definitions under the terms and indented, it is extremely simple to apply styles to a definition list so as to convert the definition list into a two column layout. This means that a definition list may be a more appropriate to use than a table is where you only have two columns of information where the first column is effectively headings for the second column.

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate