Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think the easiest is to skip the colgroup-element all together and go with simple class styling instead:</p> <pre><code>&lt;table&gt; &lt;tr class="colgroup1"&gt; &lt;th&gt;col1&lt;/th&gt;&lt;th&gt;col2&lt;/th&gt;&lt;th&gt;col3&lt;/th&gt; &lt;/tr&gt; &lt;tr class="colgroup1"&gt; &lt;td&gt;row1&lt;/td&gt;&lt;td&gt;row1&lt;/td&gt;&lt;td&gt;row1&lt;/td&gt; &lt;/tr&gt; &lt;tr class="colgroup1"&gt; &lt;td&gt;row2&lt;/td&gt;&lt;td&gt;row2&lt;/td&gt;&lt;tr&gt;row2&lt;/td&gt; &lt;/tr&gt; &lt;tr class="colgroup2"&gt; &lt;th&gt;col4&lt;/th&gt;&lt;th&gt;col5&lt;/th&gt;&lt;th&gt;col6&lt;/th&gt; &lt;/tr&gt; &lt;tr class="colgroup2"&gt; &lt;td&gt;row3&lt;/td&gt;&lt;td&gt;row3&lt;/td&gt;&lt;td&gt;row3&lt;/td&gt; &lt;/tr&gt; &lt;tr class="colgroup2"&gt; &lt;td&gt;row4&lt;/td&gt;&lt;td&gt;row4&lt;/td&gt;&lt;td&gt;row4&lt;/td&gt; &lt;/tr&gt; &lt;tr class="colgroup3"&gt; &lt;th&gt;col7&lt;/th&gt;&lt;th&gt;col8&lt;/th&gt;&lt;th&gt;col9&lt;/th&gt; &lt;/tr&gt; &lt;tr class="colgroup3"&gt; &lt;td&gt;row5&lt;/td&gt;&lt;td&gt;row5&lt;/td&gt;&lt;td&gt;row5&lt;/td&gt; &lt;/tr&gt; &lt;tr class="colgroup3"&gt; &lt;td&gt;row6&lt;/td&gt;&lt;td&gt;row6&lt;/td&gt;&lt;td&gt;row6&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Then, you can target the different colgroups easily in CSS:</p> <pre><code>.colgroup1 th { // Styles here } .colgroup2 th { // Styles here } .colgroup3 th { // Styles here } // Same for tds. </code></pre> <p><strong>Edit:</strong> I like how <a href="https://stackoverflow.com/questions/1006089/setting-rowspan-on-colgroup/1006188#1006188">Rory Fitzpatrick</a> uses multiple table bodies. If that is indeed valid, then I'd go with that solution and just put a class name on each table body tag. The CSS will remain the same</p>
 

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