CSS Width Attribute on a <COL> does not work for relative length

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to use relative length (proportions) on a COL for a table but it
does not work in IE.
Example

<TABLE>
<COL width=1*>
<COL width=3*>
<COL width=1*>

.....
</TABLE>


The HTML 4.0 spec state you can do this,

The WIDTH attribute specifies a width for each column spanned by COL. The
value must be a number in pixels, a percentage of the table width, or a
relative length expressed as i* where i is an integer. A column with
WIDTH="3*" will be allotted three times the width of a column with
WIDTH="1*". The value 0* is equivalent to the minimum width necessary for the
column's contents

Does internet explorer not support this??

Thanks
 
Internet Explorer supports Width[int](pixel) and Width[string](percentage).

More information can be found here:
http://msdn.microsoft.com/library/d...author/dhtml/reference/properties/width_3.asp

You could use script as an alternative. Here's an example.

<HTML>
<HEAD>
<SCRIPT>
function foo()
{
var c1 = document.getElementById('col1');
var originalWidth = c1.offsetWidth;
var newWidth = originalWidth * 3;
c1.style.width = newWidth;

var c2 = document.getElementById('col2');
var originalWidth = c2.offsetWidth;
var newWidth = originalWidth * 2;
c2.style.width = newWidth;

var c3 = document.getElementById('col3');
var originalWidth = c3.offsetWidth;
var newWidth = originalWidth * 0;
c3.style.width = newWidth;
}

</SCRIPT>
</HEAD>
<BODY onload="foo()">
<TABLE border="2" rules="groups">
<COL id="col1" STYLE="background-color:red">
<COL id="col2" STYLE="background:blue">
<COL id="col3" STYLE="background:green">
<TR>
<TD>This column is in the first group.</TD>
<TD>This column is in the first group.</TD>
<TD>This column is in the second group.</TD>
</TR>
<TR>
<TD>This column is in the first group.</TD>
<TD>This column is in the first group.</TD>
<TD>This column is in the second group.</TD>
</TR>
</TABLE>
</BODY>
</HTML>

Alex Scott [MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top