प्रत्येक
तत्व को स्टाइल करने के लिए CSS :nth-of-type(n) चयनकर्ता का उपयोग करें जो कि उसके पैरेंट का nth
तत्व है। आप :nth-of-type(n) चयनकर्ता को लागू करने के लिए निम्न कोड चलाने का प्रयास कर सकते हैं
उदाहरण
<!DOCTYPE html>
<html>
<head>
<style>
p:nth-of-type(2) {
background: yellow;
}
</style>
</head>
<body>
<p>This is demo text 1.</p>
<p>This is demo text 2.</p>
<p>This is demo text 3.</p>
<p>This is demo text 4.</p>
</body>
</html>