Page is a not externally linkable
- Code, Content, and Presentation
-- CSS
---- Alternate table row colours


lucy24 - 10:52 am on May 23, 2012 (gmt 0)


You're asking how to apply, say,
<tr class = "dark">
and
<tr class = "light">
to alternate rows without doing the whole thing manually?

I've done the identical thing with Regular Expressions. You just have to be a little consistent in your raw html layout, because random line breaks can cause problems. Basically you take something like

<tr>(\n<td.+\n<td.+\n {however many cells in a row} </tr>\n+)<tr>

and replace globally with

<tr class = "dark">$1<tr class = "light">

If you're rearranging an existing table the "find" part becomes

<tr(?: class = "\w+")?>

This is the exceptional RegEx that tends to work better if you do it as an unsupervised global replace, straight through from top to bottom.


Thread source:: http://www.webmasterworld.com/css/4456880.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com