Forum Moderators: open

Message Too Old, No Replies

Using colspan and cell widths in Internet Explorer

         

pforth

2:47 pm on Feb 16, 2008 (gmt 0)

10+ Year Member



When I use rowspan in a table, the width values for subsequent table columns appear to be ignored in ie. It just spaces things out evenly underneath the table cell with the rowspan set.


<body>
<table border=1><tr>
<td colspan=3>3 long columnlong columnlong column</td>
</tr><tr>
<td width=15 style="width:15px;">1</td>
<td width=15 style="width:15px;">2</td>
<td>3</td>
</tr></table>
</body>
</html>

In Firefox it looks something like this:


--------------------------------------
¦3 long columnlong columnlong column ¦
--------------------------------------
¦1¦2¦3...............................¦
--------------------------------------

Great! But In IE it looks like this:


--------------------------------------
¦3 long columnlong columnlong column ¦
--------------------------------------
¦1..........¦2...........¦3..........¦
--------------------------------------

It ignores both the width setting and the width style!

rocknbil

5:31 pm on Feb 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm sure you mean colspan. Yeah, that's the deal with tables. :-) Apply a width to the third column. If it's supposed to be a variable width, make it something like 95%. It also helps to quote all attributes, use a valid doctype [webmasterworld.com] to avoid quirks mode, and validate your code [validator.w3.org].

<tr>
<td width="15">bleh</td>
<td width="15">blah</td>
<td width="95%">meh</td>
</tr>

pforth

12:16 am on Feb 17, 2008 (gmt 0)

10+ Year Member



Definately meant colspan NOT rowspan (the code is right, the descriptive text is wrong).

Your suggestion (adding 95%) works...but I had greatly simplified the table to show the principle of what I needed. In actual fact I have more than 3 columns... like so:


<body>
<table border=1><tr>
<td colspan=3>3 long columnlong columnlong column</td>
<td>a bunch of stuff</td>
<td>and more stuff</td>
</tr><tr>
<td width=15 style="width:15px;">1</td>
<td width=15 style="width:15px;">2</td>
<td width="95%">3</td>
<td>and more stuff</td>
<td>and more stuff</td>
</tr></table>
</body>
</html>

With the suggestion implimented as I did above I get something like this:


---------------------------------------------------------
¦3 long columnlong columnlong column.........¦a....¦and..¦
¦............................................¦bunch¦more.¦
¦............................................¦of...¦stuff¦
¦............................................¦stuff¦.....¦
----------------------------------------------------------
¦1¦2¦3.......................................¦and..¦and..¦
¦............................................¦more.¦more.¦
¦............................................¦stuff¦stuff¦
----------------------------------------------------------

See how the extra columns are all squished. I want to see something more like this:


---------------------------------------------------------------------
¦3 long columnlong columnlong column¦a bunch of stuff¦and more stuff¦
---------------------------------------------------------------------
¦1¦2¦3..............................¦and more stuff..¦and more stuff¦
---------------------------------------------------------------------

This layout is dead simple to get in firefox...it seems to be impossible in IE.

I have also tried an approach using a nested table for the 1,2,3 instead of the colspan shown above. This works ok BUT in my app the 1,2,3 have repeating background images that need to be the entire height of the row. There doesn't appear to be a way to make the nested table take up the entire height of the row in either ie or firefox. This means that it works great...unless there is enough text in one of the other columns to make the row have multiple lines.