html语言中ol,<ol> - HTML(超文本标记语言) | MDN

HTML

  1.  元素 表示多个有序列表项,通常渲染为有带编号的列表。

Flow content, and if the

  1. element's children include at least one
  2. element, palpable content.

    允许的内容一个或多个

  3. 元素。这些
  4. 元素可以再包含嵌套的
    • 元素。

    标签省略 不允许,开始标签和结束标签都不能省略。

    允许的父元素 Any element that accepts flow content.

    Attributes

    这个元素包含全局属性.

    compact

    这个是布尔属性,规定了列表要用紧凑的方式渲染。这个属性的具体渲染方式由客户端决定,并不能被所有浏览器支持决定。

    Note: 不要使用这个属性,这个属性已经过时:

    1. 元素的样式应当使用 CSS 来控制,想要获得和这个属性相似的效果,使用 CSS 属性 line-height 并设置值为 80%.

    reversed

    这个布尔属性规定了列表的条目采用倒序,即最不重要的条目放在列表第一个位置。

    start

    这是整数属性,规定了列表得条目序号的开始的值。尽管列表条目的序号可能是罗马字母顺序,如 XXXI, 或者字母,这个开始的顺序总是使用数字表示。比如想要元素序号从字母 “C” 开始,使用 

    Note: 这个属性在 HTML4中弃用,但是在 HTML5 中被重新引入。

    type

    Indicates the numbering type:

    'a' 表示小写字母编号;

    'A' 表示大写字母编号;

    'i' 表示小写罗马数字编号;

    'I' 表示大写罗马数字编号;

    and '1' 表示数字编号(默认值)。

    The type set is used for the entire list unless a different

  5. element.

    Note:这个属性在 HTML4中弃用,但是在 HTML5 中被重新引入。除非列表中序号很重要(比如,在法律或者技术文件中条目通常被需要所引用),否则请使用 CSS  list-style-type 属性替代。

    使用说明

    通常,有序列表条目和它前面的编号一起显示,它的编号可以是任何形式,如数字、字母或者罗马数字,甚至可以是小子弹。而这种样式(小子弹)并没有在 HTML 页面内定义,而是在其关联的 CSS 中,使用了 list-style-type 属性。

    HTML 并没有对

    • 元素的深度和反复使用次数(overlap)作出限制。
    • 都是列表项。它们的不同点在于 
    1. 元素里条目的顺序是有意义的。 对于该选择哪一个去使用下面有个建议:尝试去更改列表项的顺序,如果其含义改变了,那么应该使用 
      1. 元素,否则使用 
    • 更合适。

    示例

    简单示例

    1. first item
    2. second item
    3. third item

    以上 HTML 输出如下:

    first item

    second item

    third item

    使用start 属性

    1. first item
    2. second item
    3. third item

    以上 HTML 输出如下:

    first item

    second item

    third item

    嵌套列表

    1. first item
    2. second item
      1. second item first subitem
      2. second item second subitem
      3. second item third subitem
    3. third item

    以上 HTML 输出如下:

    first item

    second item

    second item first subitem

    second item second subitem

    second item third subitem

    third item

    Nested

    1. and
    1. first item
    2. second item
      • second item first subitem
      • second item second subitem
      • second item third subitem
    3. third item

    以上 HTML 输出如下:

    first item

    second item

    second item first subitem

    second item second subitem

    second item third subitem

    third item

    规范

    浏览器兼容性

    特性

    Chrome

    Firefox (Gecko)

    Internet Explorer

    Opera

    Safari

    基础支持

    1.0

    1.0 (1.7 or earlier)

    1.0

    1.0

    1.0

    reversed 属性

    18

    18.0 (18.0)

    未实现

    未实现

    5.2

    Feature

    Android

    Firefox Mobile (Gecko)

    IE Mobile

    Opera Mobile

    Safari Mobile

    Basic support

    (Yes)

    1.0 (1.0)

    (Yes)

    (Yes)

    (Yes)

    reversed attribute

    (Yes)

    18.0 (18.0)

    未实现

    未实现

    (Yes)

    相关

    其他列表相关的 HTML 元素:

    • ,
    • ,

      1.  元素常用的 CSS 属性:

      the list-style property, useful to choose the way the ordinal is displayed,

      CSS counters, useful to handle complex nested lists,

      margin 属性,用来控制列表的缩进。

      这篇文章有帮助吗?

      谢谢!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值