<div class="wrap">
<p class="description"><span class="underline">:nth-child(-n)</span> - Allows us to target every sibling in a group starting from the 0th spot and working backwards (this doesn't target any siblings as you can't work backwards from the 0 place as there is no -1 sibling)</p>
<ul class="example">
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ul>
</div>
/* Setup Code */
.wrap {
padding: 40px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-family: 'Quicksand', sans-serif;
font-size: 14px;
line-height: 1.75em;
color: #595959;
}
.description,
.example {
max-width: 500px;
}
.example {
margin-top: 20px;
padding: 20px 30px 25px;
background: #f5f5f5;
display: inline-block;
columns: 3;
}
.underline {
text-decoration: underline;
}
/* End Setup */
/* Relevant Code */
li:nth-child(-n) {
color: red;
}
/* End Relevant */
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.