There seems to be an issue related to CSS pseudo-classes, specifically :last-child, but it may apply to others as well.
- If we consider the following simple HTML:
<body>
<p>Paragraph1</p>
<p>Paragraph2</p>
</body>
- And then add the following CSS:
body:last-child{
color:red;
}
<body>
<p>Paragraph1</p>
<p>Paragraph2</p>
</body>
Both paragraphs will be marked in red without any space between them
- However, when a space is added between .body and :last-child, only the second paragraph turns red. This behavior has been observed in Google Chrome, with no effect on the snippet tool.
body: last-child{
color:red;
}
<body>
<p>Paragraph1</p>
<p>Paragraph2</p>
</body>
Question: Can anyone explain why this happens? Is there more information available on the impact of including or excluding spaces for pseudo-classes?