Carson Dyle
Diamond Member
I'm trying to style something where I need to select only the first child when it immediately follows a particular tag of a certain class. The :first-child selector by itself isn't enough. Is there some other way?
I want to select this <b> tag, which is a child that immediately follows a <div> of class message.
but not select this <b> tag:
(I have no control over the source, so there's no option to rewrite it.)
I want to select this <b> tag, which is a child that immediately follows a <div> of class message.
Code:
<div class="message">
<b>I want to select this.</b> Some other text and <b>not this</b> and etc.
</div>
but not select this <b> tag:
Code:
<div class="message">
Text in which <b>this should not be selected</b> and more and more text.
</div>
(I have no control over the source, so there's no option to rewrite it.)
Last edited: