Previous Message
Next Message

Styling tables with <colgroup> & <col>

Sent by Mark J. Reed on 22 September 2006 23:11


On 9/22/06, ibn Ezra [EMAIL-REMOVED]> wrote:

> I've looked around the web and run across <colgroup> and <col> but
> I'm not sure how to string it together.

> I not really sure about the 'why' of using <colgroup>...

First, you should know that due to the CSS rendering model, <col> and
<colgroup> are both severely limited in what styling they support (at
least outside of IE, which violates the CSS rendering model to provide
them more power, breaking other things in the process).  To be
precise, there are only four things you're allowed to do with a
table-column (individual or group) style:

- set the background color
- set the width
- set up a border
- control visibility

That's it.  You can't make a column bold or in a different font or
give it centered text or any of the other things that seem perfectly
reasonable before you dive into the detailed requirements of the CSS
spec.

That said, you should use more than one <colgroup> if there's a
semantic difference between the groups of columns - as happens when
you have "sub-columns" for instance.  That way, if the semantic
distinction translates a presentation one - for instance, you might
have a group of four columns that you want to have a green background
and another group of three columns that you want to have a grey
background - the desired result can be accomplished with two
<colgroup>s and styles thereon, without having to style the individual
<col>s (much less the individual cells).  But if your only purpose for
using <colgroup> at all is to provide a place to put <col>s, then you
only need one.

And if you want to do anything not in the Gang of Four above, you
still have to fall back to assigning column-signifying classes to each
of the individual <td>s that fall into the column(s) in question.

-- 
Mark J. Reed [EMAIL-REMOVED]>
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
IE7b2 testing hub -- http://css-discuss.incutio.com/?page=IE7
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: