:nth-child(n) सेलेक्टर का उद्देश्य
:nth-child(n) सेलेक्टर पैरेंट के सभी चाइल्ड्स में से nth पोजिशन पर स्थित एलिमेंट को सिलेक्ट करता है (यदि वह निर्दिष्ट टाइप का हो)।
उदाहरण
<!DOCTYPE html>
<html>
<head>
<style>
p:nth-child(4) {
background: orange;
color: white;
}
</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>
<p>This is demo text 5.</p>
<p>This is demo text 6.</p>
</body>
</html>
यह ID 1005062657 के समान आलेख है।