HTML <ol> tag

Definitie en gebruik

<ol> De tag definieert een geordende lijst. Een geordende lijst kan numeriek of alfanumeriek zijn.

<li> De tag wordt gebruikt om elk lijstitem te definiëren.

Tip:Gebruik CSS om de lijststijl in te stellen.

Tip:Voor ongesorteerde lijsten gebruik: <ul>-tag.

Zie ook:

HTML-tutorial:HTML list

HTML DOM referentiehandleiding:Ol-objekt

CSS-tutorial:Stel de stijl van de lijst in

Voorbeeld

Voorbeeld 1

Twee verschillende geordende lijsten (de eerste lijst begint bij 1, de tweede bij 50):

<ol>
  <li>咖啡</li>
  <li>茶</li>
  <li>牛奶</li>
</ol>
<ol start="50">
  <li>咖啡</li>
  <li>茶</li>
  <li>牛奶</li>
</ol>

Try it yourself

Voorbeeld 2

Stel verschillende lijsttypen in (gebruik CSS):

<ol style="list-style-type:upper-roman">
<li>咖啡</li>
<li>茶</li>
<li>牛奶</li>
</ol>
<ol style="list-style-type:lower-alpha">
<li>咖啡</li>
<li>茶</li>
<li>牛奶</li>
</ol>

Try it yourself

Voorbeeld 3

Door CSS wordt alle beschikbare verschillende lijsttypen weergegeven:

<style>
ol.a {list-style-type: armenian;}
ol.b {list-style-type: cjk-ideographic;}
ol.c {list-style-type: decimal;}
ol.d {list-style-type: decimal-leading-zero;}
ol.e {list-style-type: georgian;}
ol.f {list-style-type: hebrew;}
ol.g {list-style-type: hiragana;}
ol.h {list-style-type: hiragana-iroha;}
ol.i {list-style-type: katakana;}
ol.j {list-style-type: katakana-iroha;}
ol.k {list-style-type: lower-alpha;}
ol.l {list-style-type: lower-greek;}
ol.m {list-style-type: lower-latin;}
ol.n {list-style-type: lower-roman;}
ol.o {list-style-type: upper-alpha;}
ol.p {list-style-type: upper-latin;}
ol.q {list-style-type: upper-roman;}
ol.r {list-style-type: none;}
ol.s {list-style-type: inherit;}
</style>

Try it yourself

例子 4

减少和扩大列表中的行高(使用 CSS):

<ol style="line-height:80%">
  <li>咖啡</li>
  <li>茶</li>
  <li>牛奶</li>
</ol>
<ol style="line-height:180%">
  <li>咖啡</li>
  <li>茶</li>
  <li>牛奶</li>
</ol>

Try it yourself

例子 5

在有序列表中嵌套无序列表:

<ol>
  <li>咖啡</li>
  <li>茶</li>
    <ul>
      <li>龙井</li>
      <li>普洱</li>
    </ul>
  </li>
  <li>牛奶</li>
</ol>

Try it yourself

属性

属性 描述
reversed reversed 定义列表顺序应该反转(9,8,7 ...)。
start 数字 定义有序列表的起始值。
type
  • 1
  • A
  • a
  • I
  • i
Specifies the type of marker to be used in the list.

Global attributes

<ol> The tag also supports Global attributes in HTML.

event attributes

<ol> The tag also supports Event attributes in HTML.

Default CSS settings

Most browsers will display the following default values <ol> Element:

ol {
  display: block;
  list-style-type: decimal;
  margin-top: 1em;
  margin-bottom: 1em;
  margin-left: 0;
  margin-right: 0;
  padding-left: 40px;
}

Try it yourself

Browser support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support