<!DOCTYPE html> <html> <head> <style> tr td:nth-of-type(2n+1){ background-color:gray; color:white; } tr td:nth-of-type(2n){ background-color:lightblue; color:white; } </style> </head> <body> <table> <tr> <td>Name</td> <td>Salary</td> <tr> <td>john</td> <td>$20,000</td> </tr> <tr> <td>david</td> <td>$30,000</td> </tr> <tr> <td>marry</td> <td>$40,000</td> </tr> </table> </body> </html>
Run
×
Share