I want to be able to target 'lorem' only in both cases using CSS only in a list with the same HTML elements (div's in this case). So when I delete the ID from the list it should still only style the first element with class 'items__item'. Does anyone have an idea?
.items {
display: flex;
flex-direction: row;
margin: 10px;
}
.items > div {
padding: 0 5px;
}
.items__item:first-child {
color: green;
}
.items__item:first-of-type {
color: green;
}
.items__item:nth-of-type(2) {
color: red;
}
<div class="items">
<div class="id">23432</div>
<div class="items__item">lorem</div>
<div class="items__item">ipsum</div>
<div class="divider">|</div>
<div class="items__item">dolor</div>
</div>
<div class="items">
<div class="items__item">lorem</div>
<div class="items__item">ipsum</div>
<div class="divider">|</div>
<div class="items__item">dolor</div>
</div>