प्रत्येक
तत्व को स्टाइल करने के लिए जो उसके माता-पिता का पहला बच्चा है, CSS का उपयोग करें:पहला-चाइल्ड चयनकर्ता।
उदाहरण
आप :फर्स्ट-चाइल्ड सिलेक्टर -
. को लागू करने के लिए निम्नलिखित कोड को चलाने का प्रयास कर सकते हैं<!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>