views:

1439

answers:

2

Does someone have a good reference for how browsers determine td width?

I have a table with 3 columns, td width set to auto, 150px, 200px, respectively. Looks pretty good in Firefox 3.5. In IE 8, columns 2 and 3 are huge, column 1 is much tinier than I'd like. I wouldn't mind the browser being a little smart (sometimes column 3 has little, sometimes more), but I don't want column 1 so small.

I've seen min-width and max-width. Some say IE doesn't understand them (maybe old versions?).

I've also seen a table-layout CSS property (we're using CSS), and maybe that's a way to go.

There is a morass of detail, and I'm looking for a good overall reference.

+1  A: 

IE 7 and above understand min-width / min-height on TD's only (IE 8 on most block-level elements), It can be frustrating as IE calculates auto widths of table cells differently. Your best bet in this situation is to be able to set some sort of width to the cells, even if it is a reference and give preference to particular cells with nowrap if you wish to prevent that.

Dustin Hansen
I think this answer is the right one for my particular situation, thanks. However, I'm going to hold out for a more comprehensive article or blog post about the problem of getting tables to work well across browsers.
dfrankow
+1  A: 

This is what I tried on FF3.5 and IE8:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html>
<head>
</head>
<body>
<table style="width: 600px;" border="1">
  <tr>
    <td style="width:auto">td1</td>
    <td style="width:150px">td2</td>
    <td style="width:200px">td3</td>
  </tr>
</table>
</body>
</html>

Both looks the same, what's your code the is significantly different from the above?

EDIT:
I tried it with doctype transitional too, same result.

o.k.w
I appreciate your attempts. I didn't post the example because I didn't want to update my live site with HTML that looked bad. The table itself was quite complicated, with column 2 being a jquery ratings widget with half-stars, and every other row was colspan=3, etc. etc.
dfrankow
We ended up solving our problem by adding style="width:100%;" to the rows with colspan="3". Without that, IE 8 would strangely squash column 1.
dfrankow