So, I’ve tried to change it and I found a way but I don’t think that’s the correct way, because I changed every single "li".
Is there a professional way?
and thanks
.ul-list {
display: flex;
background-color: #eeeeee;
color: black;
width: 400px;
justify-content: center;
align-items: center;
flex-direction: column;
}
.ul-list .ol-html {
margin: 20px;
list-style-type: none;
}
.ul-list .ol-html #slim::before {
content: counter(number) ".";
counter-increment: number 10;
}
.ul-list .ol-html #pugjs::before {
content: counter(number) ".";
counter-increment: number 11;
}
.ul-list .ol-html #haml::before {
content: counter(number) ".";
counter-increment: number 12;
}
<ul class="ul-list">
<li>
HTML
<ol class="ol-html">
<li id="slim">Slim</li>
<li id="pugjs">Pugjs</li>
<li id="haml">HAML</li>
</ol>
</li>
</ul>
3
Answers
I found the answer.
So if we want to start attributing for an ordered list using only CSS we will use
counter-increment
property.Example:
so here
counter-increment
it's 0-indexed, so to get a list that starts at 10, use 9You can add any styles to your lists, it can be numbers, emojis
If your goal it’s to start the counter for the
ol.ol-html
at 10 you can use thestart
attribute on theol