When there are two of the same elements present in the following HTML markup, I want to style them using (S)CSS without relying on JavaScript for counting and applying additional classes.
I am looking for a solution within CSS/Sass that allows me to target both instances of the element when there are exactly 2 of them.
div {
a + a {
// Styles should be applied to both 'a' tags, not just the second one
// Only if 2 'a' tags exist
}
}
<div>
<a href="/">Home</a>
<a href="/about">About</a>
</a>