Menu Close

HTML 列表

HTML 提供了三种指定信息列表的方法。 所有列表必须包含一个或多个列表元素。 列表可能包含 –

<ul> – 一个无序列表。 这将使用普通项目符号列出项目。

<ol> – 有序列表。 这将使用不同的数字方案来列出项目。

<dl> – 定义列表。 这将按照与字典中的排列方式相同的方式排列项目。

HTML 无序列表 <ul>

无序列表是一个项目的列表,此列项目使用粗体圆点(典型的小黑圆圈,使用type属性可以确定小圆圈是方块,黑四方,或圆圈)进行标记。

无序列表使用 <ul> 标签.

<!DOCTYPE html>
<html>

   <head>
      <title>HTML Unordered List</title>
   </head>
    
   <body>
      <ul>
         <li>Beetroot</li>
         <li>Ginger</li>
         <li>Potato</li>
         <li>Radish</li>
      </ul>
   </body>
   
</html>

结果:

  • Beetroot
  • Ginger
  • Potato
  • Radish

HTML 有序列表

同样,有序列表也是一列项目,列表项目使用数字进行标记。 有序列表始于 <ol> 标签。每个列表项始于 <li> 标签。

列表项使用数字来标记。

<!DOCTYPE html>
<html>

   <head>
      <title>HTML Ordered List</title>
   </head>

   <body>
      <ol>
         <li>Beetroot</li>
         <li>Ginger</li>
         <li>Potato</li>
         <li>Radish</li>
      </ol>
   </body>

</html>

结果

  1. Beetroot
  2. Ginger
  3. Potato
  4. Radish

HTML 自定义列表

自定义列表不仅仅是一列项目,而是项目及其注释的组合。

自定义列表以 <dl> 标签开始。每个自定义列表项以 <dt> 开始。每个自定义列表项的定义以 <dd> 开始。

Definition List makes use of following three tags.

  • <dl> − Defines the start of the list
  • <dt> − A term
  • <dd> − Term definition
  • </dl> − Defines the end of the list
<!DOCTYPE html>
<html>

   <head>
      <title>HTML Definition List</title>
   </head>
    
   <body>
      <dl>
         <dt><b>HTML</b></dt>
         <dd>This stands for Hyper Text Markup Language</dd>
         <dt><b>HTTP</b></dt>
         <dd>This stands for Hyper Text Transfer Protocol</dd>
      </dl>
   </body>
    
</html>

结果显示

HTML
This stands for Hyper Text Markup Language
HTTP
This stands for Hyper Text Transfer Protocol

<type>和<start>属性

您可以使用 <ol> 标签的 type 属性来指定您喜欢的编号类型。 默认情况下,它是一个数字。 以下是可能的选项 –

<ol type = "1"> - Default-Case Numerals. (默认数字)
<ol type = "I"> - Upper-Case Numerals. (大写数字)
<ol type = "i"> - Lower-Case Numerals.  (小写数字)
<ol type = "A"> - Upper-Case Letters. (大写字母)
<ol type = "a"> - Lower-Case Letters.  (小写数字)

举例

<!DOCTYPE html>
<html>

   <head>
      <title>HTML Ordered List</title>
   </head>
    
   <body>
      <ol type = "i" start = "4">
         <li>Beetroot</li>
         <li>Ginger</li>
         <li>Potato</li>
         <li>Radish</li>
      </ol>
   </body>
    
</html>
  1. Beetroot
  2. Ginger
  3. Potato
  4. Radish

 

除教程外,本网站大部分文章来自互联网,如果有内容冒犯到你,请联系我们删除!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Leave the field below empty!

Posted in HTML 教程

Related Posts