Consider the situation below:
h2[data-glossary-letter="A"]:not(:first-of-type) {
display: none;
}
h2[data-glossary-letter="B"]:not(:first-of-type) {
display: none;
}
h2[data-glossary-letter="C"]:not(:first-of-type) {
display: none;
}
<h2 data-glossary-letter="A">A</h2>
<h2 data-glossary-letter="A">A</h2>
<h2 data-glossary-letter="A">A</h2>
<h2 data-glossary-letter="A">A</h2>
<h2 data-glossary-letter="B">B</h2>
<h2 data-glossary-letter="B">B</h2>
<h2 data-glossary-letter="B">B</h2>
<h2 data-glossary-letter="C">C</h2>
<h2 data-glossary-letter="C">C</h2>
<h2 data-glossary-letter="C">C</h2>
What I need to have happen, is hide all but the first h2
of each data letter attribute. For reasons I don't understand, it hides all of them except the first one.
The output needs to be:
A
B
C
:not(:first-child) and :not(:first-of-type) not working
That's because they are not siblings.
If you change the :not selector to the parent div, it will work.
My understanding of this selector is that it is siblings only. The logic behind what I'm trying to say is "for this particular header with this attribute, the ones that are NOT the first, hide them"
But what I'm trying is not working.
Is what I'm trying to do possible? If so how should this be approached.