Reputation:
<div class="parent-div">
<p>
<b>1. Some dummy text</b><br>
<b>2. Some other dummy text</b><br>
<b>3. Some other more dummy text</b><br>
</p>
<p>
<b>4. Some dummy text</b><br>
<b>5. Some other dummy text</b><br>
<b>6. Some other more dummy text</b><br>
</p>
</div>
I want to hide the 1st most <b>
tag and wrote :
.parent-div b:first-child {display:none;}
But it's not working.
Upvotes: 2
Views: 336
Reputation: 119
.parent-div > p b:first-child {display:none;}
<div class="parent-div">
<p>
<b>1. Some dummy text</b><br>
<b>2. Some other dummy text</b><br>
<b>3. Some other more dummy text</b><br>
</p>
<p>
<b>4. Some dummy text</b><br>
<b>5. Some other dummy text</b><br>
<b>6. Some other more dummy text</b><br>
</p>
</div>
Upvotes: 1
Reputation: 103780
The issue is that with .parent-div b:first-child {display:none;}
you are hidding the first b tag of every <p>
element. To only hide the first <b>
in the first <p>
you can use .parent-div p:first-child b:first-child {display:none;}
:
.parent-div p:first-child b:first-child {display:none;}
<div class="parent-div">
<p>
<b>1. Some dummy text</b><br>
<b>2. Some other dummy text</b><br>
<b>3. Some other more dummy text</b><br>
</p>
<p>
<b>4. Some dummy text</b><br>
<b>5. Some other dummy text</b><br>
<b>6. Some other more dummy text</b><br>
</p>
</div>
Upvotes: 4