[thelist] Alternating Rows

Ben Dyer ben_dyer at imaginuity.com
Mon Oct 7 13:12:02 CDT 2002


This is too simple not to have a simple solution somewhere.

Obviously, there's a million ways to do alternating row colors but every
one of them requires hardcoding an attribute to each table row or assigning
an attribute programmatically (<CFIF CurrentRow MOD 2 IS
0>class="evenrow"</CFIF> and so on).

The problem is, I have a backend system where our clients can enter HTML
content in a WYSIWYG editor and I'd prefer for them not to have to add
classes to every row unless there was no other way.

What I've found so far is that there are selectors in CSS3 that can do
something like this (like tr:nth-child(odd) and other variants), but they
won't be widely supported in browsers any time soon.  Additionally, I know
that I can do some sort of ColdFusion loop over the content to achieve the
desired results and I have also found JavaScripts that can do similar
things at onload, but because I'd actually be modifying the display of the
data each time, I'd prefer not to do it that way.

Does anybody have any suggestions, comments, ideas on how to approach this
problem?

--Ben




More information about the thelist mailing list