Note that there are some explanatory texts on larger screens.

plurals
  1. POAlternate Table Row Colors with Multi-level Rowspans
    primarykey
    data
    text
    <p>This has been asked before, but the answer that was accepted and worked for most people doesn't actually work 100% when you get into more complex tables.</p> <p>Check out the original post here: <a href="https://stackoverflow.com/questions/3432683/alternate-row-colors-when-you-have-rowspan/3432753#3432753">Alternate row colors when you have rowspan</a></p> <p>Nick Craver's answer is a great solution for tables ulitizing rowspans. But when you start splitting the columns with colspans, and more intricacies it seems to start breaking.</p> <p>I think the problem may be related to colspan's specifically, though I haven't been able to decipher the exact problem.</p> <p>I've put together a complex table (similar to the ones I'm trying to use) that demonstrates the issues in Nick Craver's original suggestion.</p> <p>Visit the jsFiddle page that Nick set up here: <a href="http://jsfiddle.net/nick_craver/JtPw5/" rel="nofollow noreferrer">http://jsfiddle.net/nick_craver/JtPw5/</a></p> <p>And paste this table into the HTML section to test it out:</p> <pre><code> &lt;table class="altRow" cellspacing="0" cellpadding="20"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td colspan="4"&gt;Simple Row - No Rowspan, just a colspan of 4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="4"&gt;Simple Row - No Rowspan, just a colspan of 4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="4"&gt;Simple Row - No Rowspan, just a colspan of 4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;h4&gt;Rowspan of 2 - No issues here&lt;/h4&gt; &lt;/td&gt; &lt;td colspan="2"&gt; &lt;p&gt;ENERGY STAR 95 per cent AFUE or better with DC variable speed motor &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$600&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;p&gt;Zero Clearance Gas Furnace 90 per cent AFUE with a DC variable speed motor &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$300&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;h4&gt;Rowspan of 2 - No issues here&lt;/h4&gt; &lt;/td&gt; &lt;td colspan="2"&gt; &lt;p&gt;ENERGY STAR 95 per cent AFUE or better with DC variable speed motor &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$600&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;p&gt;Zero Clearance Gas Furnace 90 per cent AFUE with a DC variable speed motor &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$300&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;h4&gt;Rowspan of 2 - No issues here&lt;/h4&gt; &lt;/td&gt; &lt;td colspan="2"&gt; &lt;p&gt;ENERGY STAR 95 per cent AFUE or better with DC variable speed motor &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$600&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;p&gt;Zero Clearance Gas Furnace 90 per cent AFUE with a DC variable speed motor &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$300&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="4"&gt;Simple Row - No Rowspan, just a colspan of 4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="4"&gt;Simple Row - No Rowspan, just a colspan of 4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="4"&gt; &lt;h4&gt;Complex Row Example&lt;/h4&gt; &lt;/td&gt; &lt;td colspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, new ground source heat pump installation - that is certified by the Canadian GeoExchange Coalition &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;&amp;nbsp;$4375&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, ground source heat pump replacement - that is certified by the Canadian GeoExchange Coalition &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$1750&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, new shared ground source heat pump serving three or more homes that is certified by the Canadian GeoExchange Coalition&lt;/p&gt; &lt;/td&gt; &lt;td&gt; &lt;p&gt;One incentive per shared loop&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$0&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;One for each distribution system in the shared loop &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$0&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="4"&gt;Simple Row - No Rowspan, just a colspan of 4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="4"&gt;Simple Row - No Rowspan, just a colspan of 4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="4"&gt;Simple Row - No Rowspan, just a colspan of 4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="4"&gt; &lt;h4&gt;Complex Row Example&lt;/h4&gt; &lt;/td&gt; &lt;td colspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, new ground source heat pump installation - that is certified by the Canadian GeoExchange Coalition &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;&amp;nbsp;$4375&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, ground source heat pump replacement - that is certified by the Canadian GeoExchange Coalition &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$1750&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, new shared ground source heat pump serving three or more homes that is certified by the Canadian GeoExchange Coalition&lt;/p&gt; &lt;/td&gt; &lt;td&gt; &lt;p&gt;One incentive per shared loop&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$0&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;One for each distribution system in the shared loop &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$0&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="4"&gt; &lt;h4&gt;Complex Row Example&lt;/h4&gt; &lt;/td&gt; &lt;td colspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, new ground source heat pump installation - that is certified by the Canadian GeoExchange Coalition &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;&amp;nbsp;$4375&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, ground source heat pump replacement - that is certified by the Canadian GeoExchange Coalition &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$1750&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, new shared ground source heat pump serving three or more homes that is certified by the Canadian GeoExchange Coalition&lt;/p&gt; &lt;/td&gt; &lt;td&gt; &lt;p&gt;One incentive per shared loop&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$0&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;One for each distribution system in the shared loop &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$0&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;h4&gt;Rowspan of 2 - No issues here&lt;/h4&gt; &lt;/td&gt; &lt;td colspan="2"&gt; &lt;p&gt;ENERGY STAR 95 per cent AFUE or better with DC variable speed motor &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$600&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;p&gt;Zero Clearance Gas Furnace 90 per cent AFUE with a DC variable speed motor &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$300&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="4"&gt; &lt;h4&gt;Complex Row Example&lt;/h4&gt; &lt;/td&gt; &lt;td colspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, new ground source heat pump installation - that is certified by the Canadian GeoExchange Coalition &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;&amp;nbsp;$4375&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, ground source heat pump replacement - that is certified by the Canadian GeoExchange Coalition &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$1750&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, new shared ground source heat pump serving three or more homes that is certified by the Canadian GeoExchange Coalition&lt;/p&gt; &lt;/td&gt; &lt;td&gt; &lt;p&gt;One incentive per shared loop&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$0&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;One for each distribution system in the shared loop &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$0&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="4"&gt; &lt;h4&gt;Complex Row Example&lt;/h4&gt; &lt;/td&gt; &lt;td colspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, new ground source heat pump installation - that is certified by the Canadian GeoExchange Coalition &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;&amp;nbsp;$4375&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, ground source heat pump replacement - that is certified by the Canadian GeoExchange Coalition &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$1750&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, new shared ground source heat pump serving three or more homes that is certified by the Canadian GeoExchange Coalition&lt;/p&gt; &lt;/td&gt; &lt;td&gt; &lt;p&gt;One incentive per shared loop&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$0&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;One for each distribution system in the shared loop &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$0&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="4"&gt; &lt;h4&gt;Complex Row Example&lt;/h4&gt; &lt;/td&gt; &lt;td colspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, new ground source heat pump installation - that is certified by the Canadian GeoExchange Coalition &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;&amp;nbsp;$4375&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, ground source heat pump replacement - that is certified by the Canadian GeoExchange Coalition &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$1750&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td rowspan="2"&gt; &lt;p&gt;CAN/CSA-C448 compliant, new shared ground source heat pump serving three or more homes that is certified by the Canadian GeoExchange Coalition&lt;/p&gt; &lt;/td&gt; &lt;td&gt; &lt;p&gt;One incentive per shared loop&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$0&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;One for each distribution system in the shared loop &lt;span class="star-icon-graphic"&gt;*&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;td class="table-rebate-column"&gt; &lt;p&gt;$0&amp;nbsp;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>As you can see it's not being displayed as it should. And it appears as though even simple rows don't work correctly when they have a colspan on them. </p> <p>I've tinkered around but can't seem to figure it out. Can anyone get this issue solved once and for all!? I'm sure it would benefit many web designers who have a project that involves a lot of tabular data.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload