- The first-child selector is used to select the specified selector, only if it is the first child of its parent.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
div:first-child {
background-color: red;
color: white;
}
</style>
</head>
<body>
<div>
This is the First Div
</div>
<div>
This is the Second Div
</div>
<div>
This is the Third Div
</div>
<div>
This is the Fourth Div
</div>
<div>
This is the Fifth Div
</div>
<div>
This is the Sixth Div
</div>
<div>
This is the Seventh Div
</div>
</body>
</html>
Css:- First child
Reviewed by Network security
on
May 12, 2019
Rating:
No comments: