Here is my current code structure:
<div>
<div class="container">
<div class="title-container">
<h4 class="title blue">blue</h4>
</div>
<p>Something blue no 1</p>
</div>
<div class="container">
<div class="title-container">
<h4 class="title blue">blue</h4>
</div>
<p>Something blue no 2</p>
</div>
<div class="container">
<div class="title-container">
<h4 class="title green">green</h4>
</div>
<p>Something green no 1</p>
</div>
<div class="container">
<div class="title-container">
<h4 class="title green">green</h4>
</div>
<p>Something green no 2</p>
</div>
</div>
I am attempting to use the first-of-type
selector to hide the first h4 tag under each combination of selectors: .title.blue
and .title.green
.
My belief is that this method is not working due to the fact that the elements are not siblings. Is there a way to still utilize the first-of-type
selector in this scenario?
You can find an example pen here
h4.title.blue:first-of-type {
display: none;
}
<div>
<div class="container">
<div class="title-container">
<h4 class="title blue">blue</h4>
</div>
<p>Something blue no 1</p>
</div>
<div class="container">
<div class="title-container">
<h4 class="title blue">blue</h4>
</div>
<p>Something blue no 2</p>
</div>
<div class="container">
<div class="title-container">
<h4 class="title green">green</h4>
</div>
<p>Something green no 1</p>
</div>
<div class="container">
<div class="title-container">
<h4 class="title green">green</h4>
</div>
<p>Something green no 2</p>
</div>
</div>