HTML <ol> etiket
- Forrige side <object>
- Næste side <optgroup>
Definition og brug
<ol>
Tag definerer en ordnet liste. En ordnet liste kan være numerisk eller alfabetisk.
<li> Tag bruges til at definere hver listeEmne.
Tip:Brug CSS til at indstille listeStil.
Tip:For uliste, brug <ul> Tag.
Se også:
HTML Tutorial:HTML liste
HTML DOM Reference Manual:Ol Objekt
CSS Tutorial:Indstil listeStil
Eksempel
Eksempel 1
To forskellige ordnede lister (den første liste starter fra 1, den anden fra 50):
<ol> <li>咖啡</li> <li>茶</li> <li>牛奶</li> </ol> <ol start="50"> <li>咖啡</li> <li>茶</li> <li>牛奶</li> </ol>
Eksempel 2
Indstil forskellige listeTyper (brug 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>
Eksempel 3
Vis alle tilgængelige forskellige listeTyper med CSS:
<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>
例子 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>
例子 5
在有序列表中嵌套无序列表:
<ol> <li>咖啡</li> <li>茶</li> <ul> <li>龙井</li> <li>普洱</li> </ul> </li> <li>牛奶</li> </ol>
属性
属性 | 值 | 描述 |
---|---|---|
reversed | reversed | 规定列表顺序应该反转(9,8,7 ...)。 |
start | 数字 | 规定有序列表的起始值。 |
type |
|
angiver den type markering, der skal bruges i listen. |
Globale attributter
<ol>
Etiketten understøtter også Globale attributter i HTML.
begivenhedsattributter
<ol>
Etiketten understøtter også Begivenhedsattributter i HTML.
Standard CSS-indstillinger
De fleste browsere vil bruge følgende standardværdier til visning <ol>
Element:
ol { display: block; list-style-type: decimal; margin-top: 1em; margin-bottom: 1em; margin-left: 0; margin-right: 0; padding-left: 40px; }
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Forrige side <object>
- Næste side <optgroup>