Why if I put an element before the "p" lines, I don’t see the first line yellow? Should p:first-child select the very first p and not just a very first tag?
<style type="text/css">
p:first-child
{
background:yellow;
}
</style>
<i></i>
<p>I am a strong man. I am a strong man.</p>
<p>I am a strong man. I am a strong man.</p>
<p>I am a strong man. I am a strong man.</p>
:first-childdoes not care about the type. By adding<i></i>to your code,ibecomes the first child (assuming<style>is within<head>and the rest is in<body>, of course). Your selector wants to matchp, but sincepis not the first child anymore, your style can’t be applied.If you want to filter by type, use the CSS3
:first-of-typepseudo-class: