Reputation: 12262
Is there any way to get a .body_content p:first-child {yada yada} to work if there are elements that come before the first <p>
?
Like an H1 or H2
Trying to find the answer for: http://twitter.com/jackmcdade/status/2673916752
We need to target the first p's font-size in a div, even if there are html elements before, such as an h1 or h2.
Upvotes: 0
Views: 105
Reputation: 253318
You could possibly use:
p {
/* style as you'd like the first <p> to appear */
}
p + p {
/* style as you want other <p> tags to appear, selects a <p> that is a sibling of another <p>; I think it should style all subsequent instances of the element */
}
Upvotes: 1
Reputation: 268344
If the P isn't the first child, why would you want to apply rules as if it were? What exactly are you trying to accomplish? If you want to apply rules to only the first paragraph, you can do so with jQuery and the following code:
$(".body_content p:first").addClass("blueStuff");
Which would add a class called 'blueStuff' to the first paragraph tag within .body_content.
Upvotes: 2