CSS :first-child Selector
HTML Code
<!DOCTYPE html>
<html>
<head>
<style>
p:first-child {
background-color: yellow;
}
</style>
</head>
<body>
<p>This paragraph is the first child of its parent (body).</p>
<h1>Welcome to My Homepage</h1>
<p>This paragraph is not the first child of its parent.</p>
<div>
<p>This paragraph is the first child of its parent (div).</p>
<p>This paragraph is not the first child of its parent.</p>
</div>
</body>
</html>
HTML View
This paragraph is the first child of its parent (body).
Welcome to My Homepage
This paragraph is not the first child of its parent.
This paragraph is the first child of its parent (div).
This paragraph is not the first child of its parent.