<!DOCTYPE html>
<html>
<head>
<style>
p:last-child
{
background:#ff0000;
}
</style>
</head>
<body>
<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>
</body>
</html>
问题:
如果我改变
p:last-child
{
background:#ff0000;
}
至
:last-child
{
background:#ff0000;
}
然后整个页面变红了。为什么?p:last-child
和有什么区别:last-child
?