HighDots Forums  

col element in table not working

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss col element in table not working in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Haines Brown
 
Posts: n/a

Default col element in table not working - 12-14-2003 , 06:42 AM






I have a table with three columns, and I want the data in the first
column to align left, while that in the remaining columns to align
right:

#testTable { text-align: right; }
#leftcol { text-align: left; }

<table id="testTable">
<col id="leftCol" />
<col span="2" />
<tr>...

Properties defined in ID leftCol are not seen.

--
Haines Brown
brownh (AT) hartford-hwp (DOT) com
kb1grm (AT) arrl (DOT) net
www.hartford-hwp.com


Reply With Quote
  #2  
Old   
Steve Pugh
 
Posts: n/a

Default Re: col element in table not working - 12-14-2003 , 07:12 AM






Haines Brown <brownh (AT) teufel (DOT) hartford-hwp.com> wrote:

Quote:
I have a table with three columns, and I want the data in the first
column to align left, while that in the remaining columns to align
right:

#testTable { text-align: right; }
#leftcol { text-align: left; }

table id="testTable"
col id="leftCol" /
col span="2" /
tr>...

Properties defined in ID leftCol are not seen.
Depends on the properties, there are only a few properties that are
allowed to be defined for columns, and text-align is not one of them:
http://www.w3.org/TR/CSS2/tables.html#q4

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <steve (AT) pugh (DOT) net> <http://steve.pugh.net/>


Reply With Quote
  #3  
Old   
Martin Honnen
 
Posts: n/a

Default Re: col element in table not working - 12-14-2003 , 07:13 AM





Haines Brown wrote:

Quote:
I have a table with three columns, and I want the data in the first
column to align left, while that in the remaining columns to align
right:

#testTable { text-align: right; }
#leftcol { text-align: left; }

table id="testTable"
col id="leftCol" /
col span="2" /
tr>...

Properties defined in ID leftCol are not seen.
See
http://www.w3.org/TR/CSS2/tables.html#q4
on which CSS properties can be applied to table columns, only border,
background, width, visibility.

--

Martin Honnen
http://JavaScript.FAQTs.com/



Reply With Quote
  #4  
Old   
Rijk van Geijtenbeek
 
Posts: n/a

Default Re: col element in table not working - 12-14-2003 , 07:13 AM



On Sun, 14 Dec 2003 11:42:39 GMT, Haines Brown
<brownh (AT) teufel (DOT) hartford-hwp.com> wrote:

Quote:
I have a table with three columns, and I want the data in the first
column to align left, while that in the remaining columns to align
right:

#testTable { text-align: right; }
#leftcol { text-align: left; }

table id="testTable"
col id="leftCol" /
col span="2" /
tr>...

Properties defined in ID leftCol are not seen.
'text-align' is not supported in columns and column-groups. Only a few CSS
properties can be set for columns.

See
http://www.w3.org/TR/CSS21/tables.html#q4
and
http://ln.hixie.ch/?start=1070385285&count=1


--
Rijk van Geijtenbeek

The Web is a procrastination apparatus:
It can absorb as much time as is required to ensure that you won't get any
real work done. - J.Nielsen


Reply With Quote
  #5  
Old   
Haines Brown
 
Posts: n/a

Default Re: col element in table not working - 12-14-2003 , 02:31 PM



Rijk van Geijtenbeek <rijk (AT) opera (DOT) com> writes:

Quote:
On Sun, 14 Dec 2003 11:42:39 GMT, Haines Brown
brownh (AT) teufel (DOT) hartford-hwp.com> wrote:

I have a table with three columns, and I want the data in the first
column to align left, while that in the remaining columns to align
right:

#testTable { text-align: right; }
#leftcol { text-align: left; }

table id="testTable"
col id="leftCol" /
col span="2" /
tr>...

Properties defined in ID leftCol are not seen.

'text-align' is not supported in columns and column-groups. Only a few
CSS properties can be set for columns.

See
http://www.w3.org/TR/CSS21/tables.html#q4
and
http://ln.hixie.ch/?start=1070385285&count=1
Rijk and the others who so kindly corrected my mistake.

In reading the documents referenced here, I gather that what I'm
trying to do represents a problem not yet resolved. If so, then do I
have simply to define each cell for which I want text to align left as
members of a class having the property of text-align: left? If so,
that is easy, but not as elegant as I would have hoped.

--
Haines Brown
brownh (AT) hartford-hwp (DOT) com
kb1grm (AT) arrl (DOT) net
www.hartford-hwp.com



Reply With Quote
  #6  
Old   
Anne van Kesteren
 
Posts: n/a

Default Re: col element in table not working - 12-15-2003 , 05:26 AM



Haines Brown wrote:

Quote:
Rijk van Geijtenbeek <rijk (AT) opera (DOT) com> writes:


On Sun, 14 Dec 2003 11:42:39 GMT, Haines Brown
brownh (AT) teufel (DOT) hartford-hwp.com> wrote:


I have a table with three columns, and I want the data in the first
column to align left, while that in the remaining columns to align
right:

#testTable { text-align: right; }
#leftcol { text-align: left; }

table id="testTable"
col id="leftCol" /
col span="2" /
tr>...

Properties defined in ID leftCol are not seen.

'text-align' is not supported in columns and column-groups. Only a few
CSS properties can be set for columns.

See
http://www.w3.org/TR/CSS21/tables.html#q4
and
http://ln.hixie.ch/?start=1070385285&count=1


Rijk and the others who so kindly corrected my mistake.

In reading the documents referenced here, I gather that what I'm
trying to do represents a problem not yet resolved. If so, then do I
have simply to define each cell for which I want text to align left as
members of a class having the property of text-align: left? If so,
that is easy, but not as elegant as I would have hoped.

Correct. The W3C is currently looking into a solution for this (and
other) problems, maybe you can come up with something ;-). Applying a
'class' is the only way to go :-(

--
Anne van Kesteren
<http://www.annevankesteren.nl/>


Reply With Quote
  #7  
Old   
Rijk van Geijtenbeek
 
Posts: n/a

Default Re: col element in table not working - 12-15-2003 , 09:06 AM



On Mon, 15 Dec 2003 11:26:34 +0100, Anne van Kesteren
<mail (AT) annevankesteren (DOT) nl> wrote:

Quote:
Haines Brown wrote:
...

Quote:
trying to do represents a problem not yet resolved. If so, then do I
have simply to define each cell for which I want text to align left as
members of a class having the property of text-align: left? If so,
that is easy, but not as elegant as I would have hoped.

Correct. The W3C is currently looking into a solution for this (and
other) problems, maybe you can come up with something ;-). Applying a
'class' is the only way to go :-(
The other option is using TR > TD + TD to select each second cell in a
row, but it depends on your content if that is feasable, and it isn't
supported by MSIE.

Or if you just want to set horizontal alignment, you use <col
align=right>, which is not even deprecated...

--
Rijk van Geijtenbeek

The Web is a procrastination apparatus:
It can absorb as much time as is required to ensure that you won't get any
real work done. - J.Nielsen


Reply With Quote
  #8  
Old   
Christoph Paeper
 
Posts: n/a

Default Re: col element in table not working - 12-15-2003 , 05:16 PM



*Haines Brown* <brownh (AT) teufel (DOT) hartford-hwp.com>:
Quote:
I have a table with three columns, and I want the data in the first
column to align left, while that in the remaining columns to align
right:

#leftcol { text-align: left; }
IIRC it works in IE, although it shouldn't, because the cells are not
descendants of the columns but the rows.
By the way: IDs are case-sensitive and it's not good style to include the
element's name in the class or id name.

Quote:
table id="testTable"
col id="leftCol" /
col span="2" /
#testTable td {text-align: right}
#testTable td:first-child {text-align: left}

is very close to applying left alignment to the first column only. It's
problematic when 'colspan' and 'rowspan' come into play, though.

--
"You can only find truth with logic
if you have already found truth without it."
G.K. Chesterton


Reply With Quote
  #9  
Old   
Haines Brown
 
Posts: n/a

Default Re: col element in table not working - 12-16-2003 , 07:33 AM



Christoph Paeper <crissov2003Q4 (AT) gmx (DOT) net> writes:

Quote:
#leftcol { text-align: left; }

By the way. . .it's not good style to include the element's name in
the class or id name.
Perhaps a little philosophical and OT, but would you explain your
point? The element's name is "col," while I've assigned the ID of
"leftCol." Apparently it is this to which you refer, but I wonder what
is the basis for your objection.
--
Haines Brown
brownh (AT) hartford-hwp (DOT) com
kb1grm (AT) arrl (DOT) net
www.hartford-hwp.com



Reply With Quote
  #10  
Old   
Christoph Paeper
 
Posts: n/a

Default Re: col element in table not working - 12-16-2003 , 05:15 PM



*Haines Brown* <brownh (AT) teufel (DOT) hartford-hwp.com>:
Quote:
Christoph Paeper <crissov2003Q4 (AT) gmx (DOT) net> writes:

By the way. . .it's not good style to include the element's name in
the class or id name.

Perhaps a little philosophical and OT,
Philosophical maybe, but IMO not off-topic.

Quote:
The element's name is "col," while I've assigned the ID of "leftCol."
Who says, the style will always only be applied to documents with a 'col'
element? And will it always be "left"? Such changes more often happen with
classes over time than with ids, but why not be consistent?
E.g. #first or col#header would be more general and appropriate.

--
"It is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that."
G. H. Hardy


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.