Styling the actual first child (not just first found child)
I want to negate the leading <br>
in a <p>
tag, if it exists - and :first-child
doesn't fit the bill. Any ideas?
This <br>
must be caught. I don't want extra space at the top of a paragraph:
<p>
<br/>
Some Text
</p>
But not this one:
<p>
Some Text
<br/>
Some more te开发者_StackOverflowxt
</p>
This code, unfortunately, catches both:
p br:first-child {
display: none;
}
How do I get it to catch only leading <br>
tags? CSS3 is fine. I don't need to support dead horses.
Unfortunately this is not possible using only css. first-child
doesn't take into account regular text, but worse still, your first example, just like the second, does have a text element before the <br/>
, it's just empty space.
If you absolutely have to do this in the client-side, the only way I can think is to use some clever javascript (jQuery is probably the easiest) to remove the unwanted br
tags.
精彩评论