2

For reasons of styling I use an ol element with pseudo classes. Unfortunately I cannot start counting the list items from a desired index. What is wrong?

js fiddle

HTML

<ol start="14">
    <li>car</li>
    <li>flower</li>
    <li>garden</li>
    <li>shool</li>
    <li>river</li>
</ol>

CSS

ol {
    width: 850px;
    padding: 0;
    margin: 0 auto;
    counter-reset: item;
    list-style-type: none;
    font-size: 18px;
    line-height: 23px;
    font-weight: 400;
    font-style: normal;
}
li:before {
    content: counter(item)" ";
    counter-increment: item;
}
Niklas
  • 13,005
  • 23
  • 79
  • 119
user5372
  • 177
  • 8

2 Answers2

6

You can specify the start value in counter-reset:

counter-reset: item 13;

Unfortunately, current browsers don't support accessing to the attribute values, so something like counter-reset: item calc(attr(start) - 1); won't work. You have to set the value explicitly.

Ilya Streltsyn
  • 13,076
  • 2
  • 37
  • 57
1

The issue is that you are resetting the index with the css rule counter-reset: item

To get your desired results use counter-reset: item 13

check out teh updated fiddle here : http://jsfiddle.net/h4m5utr8/3/

olly_uk
  • 11,559
  • 3
  • 39
  • 45