<dl>
HTML <dl> Tag
The <dl> tag defines a list of definitions/descriptions (learn more about HTML lists). It is used with the <dd> and <dt> tags. The <dl> tag creates a list, the <dt> tag specifies the term, and the <dd> tag specifies the description of the term.
A <dl> content is announced by screen readers differently. Make sure that the content of each list is written in a way that it communicates its relationship to the other list items of the group.
If you use microdata, or global attributes, apply them to an entire group, it can be useful to wrap each name-value group in <dl> in a <div> element.
It is not recommended to use the <dl> element for simply creating an indentation on a page. It can obscure a description list’s meaning.
To change a description term’s indentation, use the CSS margin property. (要更改描述术语的缩进,请使用CSS margin属性。)
The <dl> tag serves as a container for the <dd> and <dt> tags.
Syntax
Syntax (语法)
The <dl> tag comes in pairs. The content is written between the opening (<dl>) and closing (</dl>) tags.
Example of the HTML <dl> tag:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<dl>
<dt>Hypertext</dt>
<dd>A system of text pages that have cross-references.</dd>
<dt>Hyperlink</dt>
<dd>A part of a hypertext document that references another item.</dd>
</dl>
</body>
</html>
Result
Attributes
Attributes (属性)
The <dl> tag supports the Global attributes and the Event Attributes.
How to style <dl> tag? Common properties to alter the visual weight/emphasis/size of text in <dl> tag:
CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit. CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element. CSS font-size property sets the size of the font. CSS font-weight property defines whether the font should be bold or thick. CSS text-transform property controls text case and capitalization. CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style.
Coloring text in <dl> tag:
CSS color property describes the color of the text content and text decorations. CSS background-color property sets the background color of an element.
Text layout styles for <dl> tag:
CSS text-indent property specifies the indentation of the first line in a text block. CSS text-overflow property specifies how overflowed content that is not displayed should be signalled to the user. CSS white-space property specifies how white-space inside an element is handled. CSS word-break property specifies where the lines should be broken.
Other properties worth looking at for <dl> tag:
CSS text-shadow property adds shadow to text. CSS text-align-last property sets the alignment of the last line of the text. CSS line-height property specifies the height of a line. CSS letter-spacing property defines the spaces between letters/characters in a text. CSS word-spacing property sets the spacing between words.