Sorry for a bad title, didn't really know how to describe better. Page looks like this
note: data-ids are random and i don't know them beforehand.
<main>
<h2 class="title">title1</h2>
<div id="1-3" class="content" data-id="1"></div>
<div id="1-2" class="content" data-id="1"></div>
<div id="1-1" class="content" data-id="1"></div>
<h2 class="title">title2</h2>
<div id="2-11" class="content" data-id="2"></div>
<div id="2-10" class="content" data-id="2"></div>
<div id="2-9" class="content" data-id="2"></div>
<h2 class="title">title3</h2>
<div id="3-18" class="content" data-id="3"></div>
<div id="3-17" class="content" data-id="3"></div>
<div id="3-16" class="content" data-id="3"></div>
</main>
is there any way to hide all but last content divs after each h2 in pure CSS? I can't target them with id or data-id individually. is there any way to select all the elements with the same unspecified attribute? so all data-id="same" are selected and then I can unhide the nth-last-child(1)? I doubt there is something like this. Is there any way to accomplish this with just CSS?
I'm currently hiding every .content if the next sibling isn't .content with js but want to know if it's possible with CSS.