प्रत्येक
तत्वों को स्टाइल करने के लिए CSS :first-child चयनकर्ता का उपयोग करें जो उसके माता-पिता का पहला बच्चा है।
उदाहरण
आप :फर्स्ट-चाइल्ड सिलेक्टर
. को लागू करने के लिए निम्नलिखित कोड को चलाने का प्रयास कर सकते हैं<!DOCTYPE html>
<html>
<head>
<style>
p:first-child {
background-color: orange;
}
</style>
</head>
<body>
<h1>Heading</h1>
<p>This is demo text.</p>
<div>
<p>This is demo text, with the first child of its parent div.</p>
<p>This is demo text, but not the first child.</p>
</div>
</body>
</html>