I have following colgroup not working properly.
<colgroup class="" style="background-color:#FF0000;"></colgroup>
Please see this jsfiddle. My styles on colgroup not working.
I have following colgroup not working properly.
<colgroup class="" style="background-color:#FF0000;"></colgroup>
Please see this jsfiddle. My styles on colgroup not working.
Share Improve this question asked Jan 24, 2012 at 8:04 Imran Qadir Baksh - BalochImran Qadir Baksh - Baloch 34.1k69 gold badges195 silver badges348 bronze badges 1- I found that, td has also contain a color. I to override colgroup color. – Imran Qadir Baksh - Baloch Commented Jan 24, 2012 at 8:09
2 Answers
Reset to default 6Most properties that you can set on colgroup
won’t have an effect, since by definitions, table cells inherit properties from tr
elements (rows), not columns or column groups (to the extent that there is inheritance).
Set, in CSS, the properties directly on the cell elements. For example, to set the background color of the first two columns, assuming that only td
markup is used for the cells, use
td:first-child, td:first-child + td {
background: #f00;
color: #fff;
}
Here is an example of colgroup:
<html> <body>
<table width="100%" border="1"> <colgroup style="background-color:#22FF22;"></colgroup> <colgroup style="background-color:#888888;"></colgroup> <colgroup style="background-color:#FF0000;"></colgroup>
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>
<tr>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
<tr>
<td>G</td>
<td>H</td>
<td>I</td>
</tr>
</table>
</body> </html>
if your code is bit different show us the more code to repy appropriately..