How to start a new list, continuing the numbering from the previous list?
Solution 1:
A much easier solution to the OP's problem is the following:
<ol start="X">
Where X is the value of the list you want to continue, so in his sample:
<ol>
<li>You can't touch this</li>
<li>You can't touch this</li>
</ol>
<p>STOP! Hammer time.</p>
<ol start="3">
<li>You can't touch this</li>
</ol>
Solution 2:
As already said, you need :before
and content
, but you also need to disable the default list numbering. This is your fixed CSS:
ol.start {
counter-reset: mycounter;
}
ol.start li, ol.continue li {
list-style: none;
}
ol.start li:before, ol.continue li:before {
content: counter(mycounter) ". ";
counter-increment: mycounter;
}
You don't need to reset the counter for ol.continue
, just continue to use your custom counter. The above code makes sure that the counter is only used for the ol.start
and ol.continue
lists.