width (HTML attribute)

Spec
Depr. Version
No HTML 2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

width=" { number | percentage } "

Description

Unless a width is set, a table will take up only the width it requires (obviously this width will depend on the amount of content in each of the table cells). Browser support for this attribute is excellent—whether the dimension is set in pixels or as a percentage—but, like many of the table element’s attributes, it’s better to use CSS to set its width.

Example

This width attribute is set to "400" pixels:

<table width="400">
  <tr>
    <th>Account Type</th>
    <th>Interest Rate</th>
  </tr>
  <tr>
    <td>Smart</td>
    <td>From 2%</td>
  </tr>
  <tr>
    <td>Young Saver</td>
    <td>From 1.6%</td>
  </tr>
</table>

Value

This attribute takes a number representing the width of the table in pixels, or a percentage.

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

It causes no compatibility issues, and has excellent support across all tested browsers.

User-contributed notes

ID:
#2
Contributed:
by lloydi
Date:
Mon, 04 Jan 2010 15:18:50 GMT

@weboncloud - you will have to ask the W3C people that one. Rest assured, it's not a mistake in the reference though :)

ID:
#1
Contributed:
by weboncloud
Date:
Wed, 14 Jan 2009 08:47:38 GMT

Wondering why the <table> width attribute is not deprecated but the <th>'s and <td>'s width attribute is deprecated?

Related Products