User:Omegatron/Striped tables

There's no easy solution for rows of alternating color, but they enhance readability quite a bit for large tables.

...After researching this and writing it up, I'm not sure how many legitimate uses it has here. But at least I learned something. :-)

CSS3
The best solution, but doesn't exist yet. But it will solve the problem in two lines of code when it comes out. not out man!

Mediawiki feature
The second best solution would be for Mediawiki to assign a class to each row dynamically when generating the page. The first row (not a header) will get class="odd", the second class="even", the third class="odd", etc. Then set styles like so:

table tr.odd { background-color: lightblue; } table tr.even { background-color: lightgreen; }

Try it with the test styles bookmarklet. (Drag bookmarklet to your toolbar, click the bookmarklet while this page is open, copy and paste the CSS into the new window, view the example tables.)

Javascript
Probably the third best solution. Won't work for people who don't use javascript, of course. Might slow down page rendering for pages with large tables?


 * http://bitesizestandards.com/bites/automatic-coloured-rows
 * http://www.surfmind.com/musings/2003/09/15/

Kludgy CSS
Probably the fourth best option. Try it with the test styles bookmarklet.

table.alternating tr+tr+tr, table.alternating tr+tr+tr+tr+tr, table.alternating tr+tr+tr+tr+tr+tr+tr, table.alternating tr+tr+tr+tr+tr+tr+tr+tr+tr, table.alternating tr+tr+tr+tr+tr+tr+tr+tr+tr+tr+tr, table.alternating tr+tr+tr+tr+tr+tr+tr+tr+tr+tr+tr+tr+tr { background-color: silver; }

table.alternating tr+tr, table.alternating tr+tr+tr+tr, table.alternating tr+tr+tr+tr+tr+tr, table.alternating tr+tr+tr+tr+tr+tr+tr+tr, table.alternating tr+tr+tr+tr+tr+tr+tr+tr+tr+tr, table.alternating tr+tr+tr+tr+tr+tr+tr+tr+tr+tr+tr+tr, table.alternating tr+tr+tr+tr+tr+tr+tr+tr+tr+tr+tr+tr+tr+tr { background-color: lightgrey; }

To be robust for very large tables, we'd need a few hundred lines of stylesheet just for this, though.

Manual HTML coding
No. Very difficult to edit, maintain, write, read, etc.