Support for the WIDTH Attribute on Tables

4/8/2010

Using tables to display information in the Microsoft Internet Explorer Mobile browser can greatly improve the way users view certain data. Use the WIDTH attribute to set the size of the table in the window. The best way to control the size of the table is to use pixel values for the WIDTH attribute. Nested tables are supported.

If you omit the WIDTH attribute, the table is rendered according to the following rules:

  • If the user selects the Default Layout menu option, the table fits perfectly to the screen width when the table appears on the screen.
  • If the user does not select the Default Layout menu, the Internet Explorer Mobile browser uses a virtual screen width of 640 pixels, and displays the table to that width.

Note

If the user selects the One Column Layout menu, the table may not be displayed as expected. For more information about Layout menu options, see Layout Meta Tag.

Unless you have a specific reason for having table widths or cell widths, we recommended that you do not use width values.

When you select the Default option in the Internet Explorer Mobile browser, the WIDTH attribute on tables and on table cells might be rejected if using the default value would result in the table being wider than the screen. In this case, the pixel widths that were specified for the table columns by using the WIDTH attribute on table cells are evenly reduced until all the columns fit horizontally into the available screen width, or until the minimum possible width is reached for all columns. Consider the following HTML code example:

<body>
<table width="300" border="0" cellpadding="0" cellspacing="0">
 <tr>
  <td width="100">column 1</td>
  <td width="100">column 2</td>
  <td width="100">column 3</td>
 </tr>
</table>


</body>

The screen on the device is only 240 pixels wide. Therefore, when the Default Layout menu is selected, the table cannot be 300 pixels wide. Accounting for a <body> element having a left margin that is 4 pixels wide and a right margin that is 4 pixels wide, the maximum width without scroll bars that is available to the table is 232 pixels. Therefore, the table displays as if the WIDTH attribute was not specified at all. The respective widths of the columns in the table are proportionally reduced so that the sum of their widths is 232 pixels. Column 1 reduces to 78 pixels wide, and column 2 and column 3 each reduce to 77 pixels.

See Also

Concepts

Limitations of the object Tag
Support for Images and Sound on a Windows Mobile Device

Other Resources

Mobile Web Site Design Overview
Internet Explorer Mobile Overview