<div id="description">
<h2>Приклад 2: використання лічильника для виділення окремих елементів списку</h2>
<p>У цьому прикладі, окремий елемент списку буде виділено відмінним кольором, використовуючи лічильник.</p>
</div>
<div id="result">
<ol class="counter-list">
<li>Перший елемент</li>
<li class="highlighted">Другий елемент</li>
<li>Третій елемент</li>
</ol>
</div>
#description {
font-style: italic;
text-align: left;
line-height: 1.5;
margin-bottom: 50px;
padding: 12px 16px;
background-color: #f7f7f7;
border: 1px solid #ccc;
}
.counter-list {
counter-reset: my-counter;
}
.counter-list .highlighted::before {
content: counter(my-counter);
counter-increment: my-counter;
background-color: yellow;
color: black;
padding: 2px 6px;
border-radius: 4px;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.