Is it possible, using only CSS, to set different styles for odd and even rows for a dynamically created table, without setting the right style for each row when I repeat the collection?
I'm not sure if this will work in a cross browser, I would prefer jQuery itself, but css-only should do the trick:
tr:nth-child(even) { ... } tr:nth-child(odd) { ... }
You can use the nth-child http://reference.sitepoint.com/css/pseudoclass-nthchild selector , although it is not supported by all browsers.
nth-child
jquery, ?
You can do this with CSS3.
tr:nth-child(2n+1) /* targets all odd rows */ tr:nth-child(2n) /* targets all even rows */
you can just use jquery and add a class for odd lines like
$("tr:nth-child(odd)").addClass("odd");
and create it using css as
.odd{background-color:#657383}