Is it possible to specify a starting number for an ordered list?

前端 未结 10 2228
梦毁少年i
梦毁少年i 2020-12-02 16:18

I have a ordered list where I would like the initial number to be 6. I found that this was supported (now deprecated) in HTML 4.01. In this specification they say that you c

10条回答
  •  执笔经年
    2020-12-02 16:57

    Via HTML, using the start attribute

    An integer to start counting from for the list items. Always an Arabic numeral (1, 2, 3, etc.), even when the numbering type is letters or Roman numerals. For example, to start numbering elements from the letter "d" or the Roman numeral "iv," use start="4".

    1. Ten
    2. Eleven
    3. Twelve

    Via CSS, using CSS counters:

    CSS counters let you adjust the appearance of content based on its location in a document. For example, you can use counters to automatically number the headings in a webpage. Counters are, in essence, variables maintained by CSS whose values may be incremented by CSS rules to track how many times they're used.

    ol {
      list-style: none;
      counter-reset: li 9; /* syntax: "counter name" "init value" */
    }
    
    ol li:before {
      counter-increment: li; /* for every appearance, add one */
      content: counter(li) ". "; /* mimic default ol list-style */
    }
    1. Ten
    2. Eleven
    3. Twelve

提交回复
热议问题