I want different styles on each column of a table. I've read that you could do that by using <colgroup>
or <col>
, but I had no luck. I have an example here, and nothing seems to change. Am I doing something wrong? Will this work on xhtml?
I know I could add a "class" attribute on each <td>
, but that seems weak.
Most of the attributes in HTML 4.01 <colgroup> are not supported in HTML5.
The <colgroup> tag specifies a group of one or more columns in a table for formatting. The <colgroup> tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row.
Definition and Usage. The span attribute defines the number of columns a <colgroup> element should span. Tip: To define different properties to a column within a <colgroup> , use the <col> tag within the <colgroup> tag.
That's correct. While colgroup
itself is supported by all browsers, this isn't true for the attributes of the inner col
element. Of possible attributes, only width
is supported on all browsers. But unlike CSS, <col width="">
only supports pixel and percentage widths.
Don't use it. Instead, create CSS classes and assign them to each td
. Yes, it sucks.
EDIT Updated link above to page with better information
Set your table-layout
to auto instead of fixed...
table {table-layout: auto;}
My personal site supports multiple themes and I see these kinds of differences all the time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With