Show only child has same class as parent

css

Solution

Only if the classes are known before hand...

div div { display: none; }

div.yellow .yellow,
div.blue .blue,
div.red .red { display: block; }

Problem

Is there a way to show a child if only parent has the same class? The tricky part of the question is parent and child does not know their class. ``` <div class="red"> <div class="red">red</div> <div class="yellow">yellow</div> <div class="blue">blue</div> </div> ``` In this case I would like show only parent and its first child. But If I change parent class from red to yellow, I would like to show only parent and its second child. Is it possible to create such a thing?

Original source