Forum:How to alternate row colour in a table?

Is it possible to create a layout on a page that contains a table so that when a new row is added to the table the background colour of the rows will change automatically?

For instance I have a table with the following table:

but if I wanted to add another row in between rows 1 and 2 it would mean that I would have to modify the bg color of every row to alternate the colors. This may be easy for tables with 10 or so rows but what about if I have 50 or more? Can code be put in to automate the alternating colour? At the moment I simply include bgcolor="#efefef" for providing the colours

150.101.2.50 01:36, 7 December 2007 (UTC)


 * Yup, if you use a sortable table it'll work. Just add class="sortable" to the table, and do the coloring to stuff inside of MediaWiki:Common.css. The sortable class's JS will add .odd and .even classes to the rows. ~ NOTASTAFF Daniel Friesen (DanTMan, Nadir Seen Fire) (talk) (tricks) (current topic) Dec 7, 2007 @ 02:25 (UTC)