定义列表的一些应用例子

INTRO: 介绍了一下定义列表的使用,并给出一些常用的例子。其实只要能正确理解定义列表的语义,它还是大有作为的。

在制作网页时经常会用到列表,而最常用的列表是无序列表Ul和有序列表Ol。其实还有一种定义列表Dl,虽然不太常用,但是实际上确有着很强的作用域。

最新的Html5中对dl元素的解释是:

The dl element represents a description list, which consists of zero or more term-description (name-value) groupings; each grouping associates one or more terms/names (the contents of dt elements) with one or more descriptions/values (the contents of dd elements).

从语义上讲,dl定义了一个定义列表,它包含了由dt和dd组成的group对,dt代表条目或名称,dd则表示了描述或具体的值。实际上定义列表是上述有序列表和无序列表的一个很好的补充。基本上所有用有序列表和无序列表无法充分表示的列表都能用定义列表来定义。本文主要就对定义列表的应用环境举一些实用的例子。

先看一些W3C规范中的例子:

引自:http://www.w3.org/TR/html401/struct/lists.html

1. 条目(人名)及条目的描述

1
2
3
4
5
6
7
8
9
10
11
12
<DL>
  <DT>Dweeb
  <DD>young excitable person who may mature
    into a <EM>Nerd</EM> or <EM>Geek</EM>
 
  <DT>Hacker
  <DD>a clever programmer
 
  <DT>Nerd
  <DD>technically bright but socially inept person
 
</DL>

2. 混合的条目及描述

1
2
3
4
5
6
7
8
9
<DL>
   <DT>Center
   <DT>Centre
   <DD> A point equidistant from all points
              on the surface of a sphere.
   <DD> In some field sports, the player who
              holds the middle position on the field, court,
              or forward line.
</DL>

3. Another application of DL, for example, is for marking up dialogues, with each DT naming a speaker, and each DD containing his or her words.

用作对话的呈现,dt用于表示说话的人,dd则表示该对话的内容。

+ 截一些图来具体看看dl的用处:


↑混合的定义列表实例

或许您对这些文章也感兴趣:

希望得到您的评论

(匿名是不被允许的)
(不会被公开)

DecImage.com 印象十二月 遥记那一季西部行

你不能逃避你的弱点,要不就奋起反击,要不就坐以待毙。如果真的是这样,为什么不从此时就开始呢?——Robert Louis Stevenson
感谢阅读我的文章,如果您需要订阅:RSS Feed | Comments RSS Feed

> 推荐两本看过的书

  • 艽野尘梦艽野尘梦全书5万多字,文言文书写,纸薄情长。读完全书,你必从此不会忘记一个叫西原的女子。
  • 幸福的建筑幸福的建筑阿兰·德波顿说他对任何的装饰都深恶痛绝,故我觉得他会和我一样喜欢北欧极简主义。
  • >友情链接

  • 零九的十二月 我在西部游走 像一个孩子一样