?
This document uses PHP Chinese website manual Release
HTML 的<li>
元素用于在列表中表示的項(xiàng)。它必須包含在父元素中:有序列表(<ol>
),無(wú)序列表(<ul>
)或菜單(<menu>
)。在菜單和無(wú)序列表中,列表項(xiàng)通常使用項(xiàng)目符號(hào)來(lái)顯示。在有序列表中,它們通常在左側(cè)以升序計(jì)數(shù)器顯示,如數(shù)字或字母。
內(nèi)容類別 | 無(wú) |
---|---|
允許的內(nèi)容 | 流量?jī)?nèi)容。 |
標(biāo)簽省略 | 如果列表項(xiàng)緊跟著另一個(gè)<li>元素,或者其父元素中沒(méi)有更多內(nèi)容,則可以省略結(jié)束標(biāo)記。 |
允許父母 | 一個(gè)<ul>,<ol>或<menu>元素。盡管不是一致的用法,但過(guò)時(shí)的<dir>也可以是父級(jí)。 |
允許的 ARIA 角色 | menuitem,menuitemcheckbox,menuitemradio,選項(xiàng),演示文稿,收音機(jī),分隔符,選項(xiàng)卡,樹形結(jié)構(gòu) |
DOM 接口 | HTMLLIElement |
該元素包含全局屬性。
value
這個(gè)整數(shù)屬性表示由<ol>
元素定義的列表項(xiàng)的當(dāng)前序號(hào)值。該屬性唯一允許的值是一個(gè)數(shù)字,即使該列表以羅馬數(shù)字或字母顯示。列出這一項(xiàng)后面的項(xiàng)目,繼續(xù)從值集編號(hào)。所述值屬性具有用于無(wú)序列表(沒(méi)有意義<ul>
)或菜單(<menu>
)。
注意:此屬性在 HTML4中 已被棄用,但在 HTML5 中重新引入。
注意:在 Gecko 9.0 之前,負(fù)值被錯(cuò)誤地轉(zhuǎn)換為0.從 Gecko 9.0 開始,所有整數(shù)值都被正確解析。
type
此字符屬性指示編號(hào)類型:
a
: 小寫字母
A
: 大寫字母
i
:小寫的羅馬數(shù)字
I
:大寫的羅馬數(shù)字
1
:數(shù)字
如果有的話,此類型將覆蓋其父元素<ol>
所使用的類型。
用法說(shuō)明:此屬性已被棄用:list-style-type
改為使用 CSS 屬性。
<ol> <li>first item</li> <li>second item</li> <li>third item</li></ol>
上面的 HTML 會(huì)輸出:
第一項(xiàng)
第二項(xiàng)
第三項(xiàng)
<ol type="I"> <li value="3">third item</li> <li>fourth item</li> <li>fifth item</li></ol>
上面的 HTML 會(huì)輸出:
第三項(xiàng)
第四項(xiàng)
第五項(xiàng)
<ul> <li>first item</li> <li>second item</li> <li>third item</li></ul>
第一項(xiàng)
第二項(xiàng)
第三項(xiàng)
有關(guān)更詳細(xì)的示例,請(qǐng)參閱 <ol> 和 <ul> 頁(yè)面。
Specification | Status | Comment |
---|---|---|
HTML Living StandardThe definition of '<li>' in that specification. | Living Standard | |
HTML5The definition of '<li>' in that specification. | Recommendation | |
HTML 4.01 SpecificationThe definition of '<li>' in that specification. | Recommendation | The type attribute has been deprecated. |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | 1 | (Yes) | (Yes) | (Yes) |
value | (Yes) | (Yes) | 1 | (Yes) | (Yes) | (Yes) |
type | (Yes) | (Yes) | 1 | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | 1 | (Yes) | (Yes) | (Yes) |
value | (Yes) | (Yes) | (Yes) | 1 | (Yes) | (Yes) | (Yes) |
type | (Yes) | (Yes) | (Yes) | 1 | (Yes) | (Yes) | (Yes) |