Instead of using an "until" selector, you can achieve the desired effect by following these steps.
Elements starting from .specific
will be styled in red, while the rest will be green. Customize the styles as needed, and observe the difference between items 1-5 and those after.
a {
background: green;
}
a.specific,
a.specific ~ a {
background: red;
}
<div class="parent">
<a id="1">qwe</a>
<a id="2">wqe</a>
<a id="3">wqe</a>
<a id="4">wqe</a>
<a id="5" class="specific">qwe</a>
<a id="6">qwe</a>
<a id="7">qwe</a>
</div>
For more information on the general sibling combinator, visit this documentation.
The general sibling combinator (~) separates two selectors and matches
the second element only if it follows the first element (though not
necessarily immediately), and both are children of the same parent
element.
If you want the 5th item to be green, use a.specific ~ a
. If you prefer it to be red, stick with the code provided in the snippet above.