Lets say I have a simple list like so:
<ol>
<li class="count">one</li>
<li class="count">two</li>
<li class="count">three</li>
<li class="count">four</li>
<li>blabla</li>
<li class="count">five</li>
<li class="count">six</li>
<li>blabla</li>
<li class="count">seven</li>
</ol>
Now I only want to number list items with the class 'count'
So If I add the CSS:
li {
list-style-type: decimal;
}
and then remove the list-style-type for list items without the class:
li:not(.count) {
list-style-type: none;
}
I get this:
li {
list-style-type: decimal;
}
li:not(.count) {
list-style-type: none;
}
<ol>
<li class="count">one</li>
<li class="count">two</li>
<li class="count">three</li>
<li class="count">four</li>
<li>blabla</li>
<li class="count">five</li>
<li class="count">six</li>
<li>blabla</li>
<li class="count">seven</li>
</ol>
The obvious problem here is that the list items without the class are also 'counted' here, just not shown.
So in the above example, the list should be numbered to 7 - with the numbering skipping the list items without the class. Can this be done with CSS?
<ol>
– Ailsun<ol>
– Fructidor