Forum Moderators: not2easy

Message Too Old, No Replies

Styling tables with <col>

Why doesn't it work with Opera and Moz?

         

Wertigon

2:15 pm on Aug 8, 2003 (gmt 0)

10+ Year Member



Trying to style together some columns using <colgroup> and <col>, and do some stuff about it - like adding monospace and text aligned to the right with certain columns.

Something like

<table>
<colgroup>
<col>
<col class="numbers">
</colgroup>
<thead>
<tr>
<th>Name</th>
<th>Cost</th>
</tr>
</thead>
<tbody>
<tr>
<td>Flowers</td>
<td>10.0</td>
</tr>
<tr>
<td>Vase</td>
<td>5.0</td>
</tbody>
</table>
And the CSS:

.numbers {
text-align : right;
font-family : monospace;
}

It works in IE, but doesn't in Opera or Mozilla for some reason. I'm confused here - is it Moz and Opera that simply doesn't support this yet, or is IE going against the standard like usual? Which one is "right" and "wrong" about this?

DrDoc

2:25 pm on Aug 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



have you tried this?

.numbers td, .numbers.th {
...
}

Wertigon

2:43 pm on Aug 8, 2003 (gmt 0)

10+ Year Member



Yes, I tried it... No go.

Ryan8720

3:44 pm on Aug 8, 2003 (gmt 0)

10+ Year Member



You aren't using them properly.

You have to have a closing tag for each COL tag.

see here >> [w3schools.com...]

drbrain

4:01 pm on Aug 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is an old bug in mozilla: [bugzilla.mozilla.org...] which is a few days shy of being fixed! It only took 4 years 3 months :)

Ryan8720

6:16 pm on Aug 8, 2003 (gmt 0)

10+ Year Member



The COL, COLGROUP, THEAD, TBODY are all useless anyway.

drbrain

10:42 pm on Aug 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



They're quite useful, especially for highlighting specific columns of a table, like totals. In print contexts, you should be able to tell thead and tfoot to be repeated on every page, for tables that span multiple pages.

I tried to use col on a calendar to highlight weekends, but then found bug 4510. I'm glad its getting fixed RSN (along with another bug I filed 10 months ago, and submitted a patch for).

Wertigon

9:17 am on Aug 9, 2003 (gmt 0)

10+ Year Member



You aren't using them properly.

You have to have a closing tag for each COL tag.

see here >> [w3schools.com...]

Actually...

In HTML the <col> tag has no end tag.

Since I'm not using XHTML I am using them properly. :p

Anyhow, I'd say that <colgroup> and <col> are both really useful. And I think I've found a way to make use of <thead>, <tbody> and <tfoot> as well.

Hmm. For once IE is better at handling the standard than Moz and Opera is. I'm impressed. Oh well, I'll just use the "Too bad for Moz/Opera" rule and style it anyway, then wait for them to catch up. Thanks for the help, appreciate it. :)