AKalair Posted February 20, 2009 Share Posted February 20, 2009 Hello, How can I use CSS to have alternating colours for the background of a table. For instance the first row is black, the next white and so on. Thank You Link to comment https://forums.phpfreaks.com/topic/146089-alternating-table-colours-in-css/ Share on other sites More sharing options...
haku Posted February 20, 2009 Share Posted February 20, 2009 .black { background-color:black; } .white { background-color:white; } <tr class='black'> // stuff in row </tr> <tr class='white'> // stuff in row </tr> <tr class='black'> // stuff in row </tr> etc. Link to comment https://forums.phpfreaks.com/topic/146089-alternating-table-colours-in-css/#findComment-766939 Share on other sites More sharing options...
TheFilmGod Posted February 21, 2009 Share Posted February 21, 2009 CSS3 method: tr:nth-child(odd) { background-color:#eee; } tr:nth-child(even) { background-color:#fff; } Link to comment https://forums.phpfreaks.com/topic/146089-alternating-table-colours-in-css/#findComment-767562 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.