FULL STACK   ·   UI   ·   UX   ·   GRAPHICS   ·   DEVELOPER   ·   INSTRUCTOR

Adam Khoury

Donate funds to show love and support

Click the button below to donate funds securely online. You can use your PayPal account or a credit card.

Your donations help free up my time to produce more content and assist in covering server costs. It's also a great way to say thanks for the content!

Application Configuration

Adam will be adding options here soon.

nth child Tutorial Selector Alternate Colors

Published :
Author :
Adam Khoury
Learn to create CSS alternating style logic for your elements by using the nth-child pseudo-class selector in your HTML documents. <!DOCTYPE html> <html> <head> <style> .myTable { width:100%; border-collapse:collapse; } .myTable td { padding:8px; border:#999 1px solid; } .myTable tr:nth-child(even) { /*(even) or (2n+0)*/ background: #A4D1FF; } .myTable tr:nth-child(odd) { /*(odd) or (2n+1)*/ background: #EAF4FF; } </style> </head> <body> <table class="myTable"> <tr> <td>Row 1 content</td> </tr> <tr> <td>Row 2 content</td> </tr> <tr> <td>Row 3 content</td> </tr> <tr> <td>Row 4 content</td> </tr> </table> </body> </html>