I want something like jQuery :last selector, but in pure css.
How can I get only a pair of 'z' , if I did not know its index in the DOM structure! . or how to get the last child of the '.area' class? I see that this CSS3 gets the last element , but it does not work in my case, because I have another parent element in the parent element.
p.area:last-child does not work!
I found a solution when we know how many elements will be with the .area class.
The selector is as follows: p.area ~ p.area ~ p.area But when we didn’t know ... I think ... just for fun =)
<div> <h1>This is a heading</h1> <p class="">The first paragraph.</p> <p class="area">The x paragraph.</p> <p class="area">The y paragraph.</p> <p class="area">The z paragraph.</p> <p class="">The last paragraph.</p> </div
source share