Forum Moderators: not2easy

Message Too Old, No Replies

"text-align:center" on a <col> of <colgroup>?

i couldn't get it to work with Opera and Mozilla.

         

mupo

4:07 pm on Aug 3, 2004 (gmt 0)

10+ Year Member



Is it somehow possible to use

text-align:center

on colgroups to align the content of a whole column in a centered table?
It didn't work in Opera and Mozilla, but in IE6.

Example:

<table border="1" summary="test" cellspacing="0">
<caption>test</caption>

<colgroup>
<col style="text-align: center" />
<col style="text-align: left" />
</colgroup>

<tr>
...

Thanks for your answers.

drbrain

4:18 pm on Aug 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



col align is deprecated in favor of CSS. (It can only be implemented at the cost of CSS compliance, memory footprint, or page load times.)

See bug 915 [bugzilla.mozilla.org] for all the gory details, especially comment 162 [bugzilla.mozilla.org].

(No, do not post to this bug. Any question you could possibly have has already been answered therein.)

[edited by: drbrain at 5:05 pm (utc) on Aug. 3, 2004]

drbrain

4:20 pm on Aug 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh, and the align attribute won't work in Mozilla/Opera for the same reason that col align isn't supported. table cells do not inherit from col/column groups. Why they can't do this is explained in full in bug 915 as mentioned in my previous post.

choster

4:20 pm on Aug 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think either Gecko or Opera browsers support CSS on <col> or <colgroup>, although they do recognize HTML 4.0 styling attributes (e.g. <col align="center">).

mupo

4:47 pm on Aug 3, 2004 (gmt 0)

10+ Year Member



Hmmm, ok,

that means taht i have to define a class for example "tacenter" with "text-align: center" and apply it to all TD's:

1: <td class="tacenter">..</td>
2: <td class="tacenter">..</td>
3: <td class="tacenter">..</td>
4: <td class="tacenter">..</td>

Well ok, thanks for your fast answers!

drbrain

4:58 pm on Aug 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You should also be able to use CSS3's :nth-child() [w3.org] selector newer versions of Mozilla and Opera. Beware the colspan.