Striping a HTML table with merged cells

A common style applied to HTML tables with lots of data is to make them striped, i.e. set the background color of alternate rows. This is easy to do when each tr represents an individual row to be striped, but if you have cells merged across multiple rows then this doesn't work.