I need to select <b> tags but only if that is the only content inside of a <p>. So for example, select the b in <p><b>hello</b></p> but not in <p><b>hello</b> world</p>. Is this possible? :only-child doesn't do it.
Asked
Active
Viewed 236 times
4
Drew Harwell
- 41
- 1
-
in order to do what? – Temani Afif Mar 22 '20 at 22:41
-
5AFAIK, CSS selectors don't know anything about text nodes, so I don't think this is possible without JS :( – Agus Zubiaga Mar 22 '20 at 22:44
-
1As @AgusZubiaga said, this is not possible with just CSS. Why is this necessary? Could you use perhaps `span`s for the text nodes? – kzhao14 Mar 22 '20 at 22:56
1 Answers
-1
You can simply find a common class for all tags you want to change and insert it inside the element (< b class="">). In the CSS you can then edit the class according to your wishes.
Eduard
- 121
- 7