Alternating Row Color in HTML Tables
Tuesday, December 4, 2007 12:12:13 PM
php, css, table, javascript, hmtl
HTML tables are nice for presenting data. However, with wide tables, you might want to alternate the line colors (e.g. blue and white) for improving readability. You may code this by hand, maybe assigning different CSS classes to the
Tags. Some wiki enginges do this automatically for you (e.g. TWiki). Recently I've found some nice howtos for automating table striping:
Lorenzo E. Danielsson shows how table striping with PHP works.
David F. Miller explains how to use JavaScript and CSS for alternating row colors in an HTML table.
And David Storey demonstrates how CSS3 supports alternating row colors.
Image stolen from David F. Miller's blog post