start="number"
unfortunately doesn't automatically change based on the numbering before it.
Another way to do this that may fit more complicated needs is to use counter-reset
and counter-increment
.
Problem
Say you wanted something like this:
1. Item one
2. Item two
Interruption from a <p> tag
3. Item three
4. Item four
You could set start="3"
on the third li
of the second ol
, but now you'll need to change it every time you add an item to the first ol
Solution
First, let's clear the formatting of our current numbering.
ol {
list-style: none;
}
We'll have each li show the counter
ol li:before {
counter-increment: mycounter;
content: counter(mycounter) ". ";
}
Now we just need to make sure the counter resets only on the first ol
instead of each one.
ol:first-of-type {
counter-reset: mycounter;
}
Demo
http://codepen.io/ajkochanowicz/pen/mJeNwY
ol
list-style: none
li
&:before
counter-increment: mycounter
content: counter(mycounter) ". "
&:first-of-type
counter-reset: mycounter
<ol>
<li>Item one</li>
<li>Item two</li>
</ol>
<p>Interruption</p>
<ol>
<li>Item three</li>
<li>Item four</li>
</ol>
<p>Interruption</p>
<ol>
<li>Item five</li>
<li>Item six</li>
</ol>
Now I can add as many items to either list and numbering will be preserved.
1. Item one
2. Item two
...
n. Item n
Interruption from a <p> tag
n+1. Item n+1
n+2. Item n+2
...