Table width demonstration

Old page: content not substantially revised since November 1998.

Table cells sized in percent can be interpreted differently by Netscape and by MSIE (3). This page was originally created in order to explain and demonstrate what the problem was, and to suggest that this was the reason that percentage column widths were not included in the HTML3.2 specification - whose stated purpose, after all, had been to codify the HTML features that were available in common in the browser versions that were current at the time HTML3.2 was formulated.

[Note that in the HTML4.0 Transitional specification, the situation is a curious one, in as much as the DTD defines the cell width attribute to be CDATA, meaning that pretty much anything will pass syntax validation; but the descriptive text of the specification calls for the cell width to specify a number of pixels.]

The test material

Here's a copy of the test material. If you're viewing this on Netscape, or on a version of MSIE later than 3.x, then presumably you won't see the problem. Please refer to the screenshots later.

Demonstration of table with width 50%
cell of width 35% this is the residue when the width is unspecified

Workaround

Apparently there's a workaround for this. If you put explicit percentage widths on all of the columns, taking care to make them add up to 100%, then it produces the same result on MSIE3 as it does on Netscape.

Demonstration of table with width 50%
cell of width 35% second cell, specifying explicit width percent to make up 100

Screen shots


NS 4 screen shot:

[NS4 screenshot]

MS IE 3 screen shot:

[MS IE 3 screenshot]

MS IE 4 screen shot:

[MS IE 4 screenshot]

Conclusion

There are other browsers/vendors than these two, but as far as I'm aware, none of them are harmed by the techniques presented here.

NS interpreted the 35% cell width as 35% of the table width, leaving a residue of 65% of the table width; MS IE 3 interpreted cell width of 35% as meaning 35% of the window width (70% of the table width), leaving only 15% of the window width (30% of the table width) as the residue. (This is probably the reason why specifying cell widths in percent was omitted from the HTML3.2 recommendation).

It looks as if this was changed in MSIE4, so as to more nearly match what Netscape does. However, by using the above workaround, it seems that even MSIE3 can be persuaded to produce a similar result.

N.B: the tests did not include mixing of pixel-width and percentage-width cells in the same table.


History

This page was created originally for a specific purpose: to document and demonstrate the problem. Something seemed to be needed, since the question kept coming up in usenet discussions, and it seemed to be useful to have a web page to point to when the problem was discussed. It wasn't meant to be a full-scale tables tutorial.

In a subsequent usenet posting <364df759.21788188@news.enteract.com>, I was rebuked by one W.Schlake for calling attention to this workaround on my page. The implication seemed to be that I was suspected of having plagiarised this workaround from his table tutorial web page. I should like to make it clear that I have made no claim to originality for this workaround. I was already aware of it before noticing that it was mentioned on his table tutorial page, and I had included it on my page at the suggestion of others who thought it would be helpful.

However, I'm not aware that there is any documentation from MS or NS which specifies that this behaviour is designed to be correct. If in fact there is, I'll be only too glad to cite it.


ajf