If you're looking to style a specific <p>
element within a <div>
, consider using the CSS selector :nth-child
. For example, to target the 2nd <p>
inside a <div>
, you can use div p:nth-child(2)
.
Alternatively, as suggested by Marc B in the comments, you could give the <p>
a class for easier targeting.
<div>
<p>Hello, </p><p class='lionel'>is it me you're</p><p> looking for?</p>
</div>
To specifically style the middle <p>
with the class "lionel", you can do:
div p.lionel {
font-weight: bold;
}
You can also achieve the same effect by targeting the same <p>
using the :nth-child()
selector like this:
div p:nth-child(2) {
font-weight: bold;
}