Using the WIDTH Attribute on Tables

The use of tables to display information can greatly enhance 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 table size is to use pixel values for the WIDTH attribute. Nested tables are supported.

If you choose to leave out the WIDTH attribute, the table is rendered according to the following rules:

  • If the Fit to Screen option is selected, the table fits perfectly to the screen width.
  • If Fit to Screen is not selected, Pocket Internet Explorer uses a virtual screen width of 640 pixels and renders the table to a width of 640 pixels.

Unless there is a specific reason for having table or cell widths, it is recommended that width values be omitted. In Pocket Internet Explorer 2000, the ALIGN attribute is supported on the <tr> and <td> tags but not on the <table> tag. In Pocket Internet Explorer 2002, the ALIGN attribute on <table> tags is supported.

In Pocket Internet Explorer 2002 and higher, with the Fit to Screen option selected, the WIDTH attribute on tables and table cells might not be honored if it would result in the table being wider than the screen. When this happens, the pixel widths specified for the table columns via the WIDTH attribute on table cells are evenly reduced until all columns fit horizontally into the available screen width or until the minimum possible width is reached for all columns. Consider the following HTML 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>

Because the screen is only 240 pixels wide on the device, with Fit to Screen on, the table cannot be 300 pixels wide. Accounting for the 4-pixel left and right margin on the <body> element, the maximum width available to the table without scroll bars is 232 pixels, so the table behaves as if the WIDTH attribute wasn't specified at all. The column' widths are proportionally reduced so that they sum to 232. Column 1 reduces to 78 pixels wide, and columns 2 and 3 reduce to 77 pixels each.

See Also

<object> Tag Limitations

Designing Images and Sound for Mobile Devices

HTML Reference for Pocket Internet Explorer

Mobile Web Site Design Overview

Pocket Internet Explorer Overview

Send feedback on this topic to the authors.

© 2005 Microsoft Corporation. All rights reserved.