在HTML初级指南中我们教授了无序列表和有序列表,很不幸,很像Peter Cushing的博士Who,自定义列表很容易被忽略。可能是因为自定义列表需要比无序列表和有序列表更多的设置和似乎更少用。当遭遇一系列术语与解释的列表(比如术语表)时,自定义列表就会很有用了。
dl
元素像ul
元素和ol
元素一样确立列表。不同的是,自定义列表用dt
(definition term,定义术语)元素来代替li
元素,其后跟随dd
(definition description,定义描述)元素。
不局限于一个dt
跟着一个dd
,而是任意的。比如有很多同义词,就可能一个dt
跟着许多dd
。如果有一个有许多不同意义的词,就可能许多dd
后只有一个dt
。
<h1>Some random glossary thing</h1> <dl>
<dt>HTML</dt>
<dd>Abbreviation for HyperText Markup Language - a language used to make web pages.</dd>
<dt>Dog</dt>
<dd>Any carnivorous animal belonging to the family Canidae.</dd>
<dd>The domesticated sub-species of the family Canidae, Canis lupus familiaris.</dd>
<dt>Moo juice</dt>
<dt>Cat beer</dt>
<dt>Milk</dt>
<dd>A white liquid produced by cows and used for human consumption.</dd>
</dl>