HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> p:nth-child(odd){ color: red; } p:nth-child(even){ color: blue; } </style> </head> <body> <h1>CSS :nth-child() Selector</h1> <h2>Heading 2</h2> <p>This is 3rd(odd) child (p) of its parent (body).</p> <p>This is 4th(even) child (p) of its parent (body).</p> </body> </html>
OUTPUT
×

Save as Private