| Depr. | Version |
|---|---|
| Yes | HTML 2 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ | CH2+ |
|---|---|---|---|---|
| Full | Full | Full | Full | Full |
Syntax
Description
Unless a width is set, a
td (and also th) will take up only the width it requires (obviously this will
depend on the amount of content in each of the table cells). You can use
the width attribute to fix the width to a value of
your choosing, regardless of the content of the table cell, but be aware
that this is a deprecated attribute. Width should be set using
CSS.
If different
width attributes are applied to several cells
within the same column, the browser will render the column with the
largest width value specified. It could be understood, therefore, that
width is really a minimum width value: a table cell
will increase in size if the content cannot be wrapped (as may be the
case, for example, with a wide image, or a string of text that contains no
spaces, such as a web site address).
Example
Here, the
width attribute is set to
"50%":
<tr> <td width="50%">Smart</td> <td width="50%">From 2%</td> </tr>
Value
This attribute takes as
its value a number that represents the width of the td
element 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.