Go to main content
Bypass navigation bar HTML Reference HTML Tags HTML Tutorials
Bypass language selection
Bypass location bar

Location: Home > HTML Reference > HTML Tags > HTML dl tag

Bypass main content

HTML dl tag

Note: If you don't know what an element/tag is and/or how you must use it we recommend you read our HTML tags and attributes tutorial, which you can find in our HTML tutorials section.

Bypass main content

Description

The HTML dl element inserts a definitions list, composed by two elements: terms (HTML dt element) and descriptions (HTML dd element). In definition lists, terms can be associated to one or more descriptions and viceversa. The way terms and descriptions are associated is arbitrary and left to the author's consideration.

Examples

Below, a definition list is set up with different examples of association between terms and descriptions.

Code
<dl>
<dt>HTML 2.0</dt>
<dt>HTML 3.2</dt>
<dt>HTML 4.01</dt>
<dd>Hyper Text Markup Language based on SGML and not compatible with XML. This language is used to construct web pages.</dd>
<dt>XHTML 1.0</dt>
<dd>Extensible Hyper Text Markup Language based on XML, a subset of SGML. This language is used to construct web pages.</dd>
<dd>Language created to reduce the presentational orientation of its predecessors.</dd>
<dt>XHTML 1.1</dt>
<dd>Extensible Hyper Text Markup Language based on XML, a subset of SGML. This language is used to construct web pages and isn't backward compatible with HTML due to the lack of the "lang" attribute.</dd>
</dl>
View
HTML 2.0
HTML 3.2
HTML 4.01
Hyper Text Markup Language based on SGML and not compatible with XML. This language is used to construct web pages.
XHTML 1.0
Extensible Hyper Text Markup Language based on XML, a subset of SGML. This language is used to construct web pages.
Language created to reduce the presentational orientation of its predecessors.
XHTML 1.1
Extensible Hyper Text Markup Language based on XML, a subset of SGML. This language is used to construct web pages and isn't backward compatible with HTML due to the lack of the "lang" attribute.

In the next example, a chat conversation is represented by a list, where the names of the persons are shown with the HTML dt element and their lines by the HTML dd element.

Code
<dl>
<dt>Charles</dt>
<dd>Hi</dd>
<dd>Are you there?</dd>
<dt>Susan</dt>
<dd>Hi!!</dd>
<dd>Yes, I'm here...</dd>
<dt>Charles</dt>
<dd>How are you!?</dd>
<dt>Susan</dt>
<dd>Fine, I was hoping to find you here... I need to tell you something</dd>
</dl>
View
Charles
Hi
Are you there?
Susan
Hi!!
Yes, I'm here...
Charles
How are you!?
Susan
Fine, I was hoping to find you here... I need to tell you something

Attributes

id (name)

The "id" attribute assigns an identifier to the associated element. This identifier must be unique in the document and can be used to refer to that element in other instances (e.g., from client-side scripts).

<p id="paragraph1">This is the first paragraph, named "paragraph1". To dynamically change its properties use this identifier.</p>

class (cdata)

The "class" attribute assigns a class name (or a list of class names separated by spaces) to the container element. It is used together with style sheets and tells the browser the class (or classes) to which the element is associated.

A class gives presentational attributes to elements (read more at the Cascading Style Sheets tutorial).

<p class="references">This article is based on the book "Wind in the trees" by Jhon L. Brooks</p>
<p class="references important">This article is based on the book "Wind in the trees" by Jhon L. Brooks... and is more important than the one before.</p>

style (style)

This attribute is used to define presentational attributes for the containing element, and its value should be composed by style sheets properties. Although in some cases it can become useful, a better practice is to place presentational attributes in external files, relating them to elements with the "class" attribute. This way you keep the semantic and presentational parts of your document separated.

You can find more information about presentational attributes at the Cascading Style Sheets tutorial.

<p style="color: #0000FF; font-size: 12pt">This is a paragraph with a defined style.</p>
<p>And this is another text without style.</p>

title (text)

The purpose of this attribute is to provide a title for the element. Its value must be a short and accurate description of the element. Browsers usually render it as a "tool tip" when the user puts the mouse pointer over the element for a short period of time.

Code
<a title="HTMLQuick.com" href="http://www.htmlquick.com">HTML code</a>
View

lang (langcode)

Specifies the language of an element's content. The default value is "unknown".

When writing XHTML 1.0 documents, the attribute used to specify the language of an elements is "xml:lang". For forward and backward compatibility both attributes can be used simultaneously as in the example below. Note that in XHTML 1.1 the "lang" attribute has been completely replaced by "xml:lang" and its use is no longer valid.

<p lang="en" xml:lang="en">This is a paragraph in English.</p>
<p lang="es" xml:lang="es">Este es un párrafo en español.</p>

dir

This attribute indicates the direction in which the texts of the element must be read. This includes content, attribute values and tables. It has two possible values that are case-insensitive:

  • RTL: Right to left.
  • LTR: Left to right.
<q lang="he" dir="rtl">...an Hebrew quotation...</q>

Events

  • onclick
  • ondblclick
  • onmousedown
  • onmouseup
  • onmouseover
  • onmousemove
  • onmouseout
  • onkeypress
  • onkeydown
  • onkeyup

See a complete list and information about events in HTML

Diseño y desarrollo: Latitud29.com

Links and logos|Contact|Beyond HTML|Tools and resources|Sitemap|Webmaster|Donate