English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The width attribute specifies the width of the table cell. Usually, the cell occupies the space required for its display content. The width attribute is used to set the predefined width of the cell.
Table cells with predefined width:
<table border="1" width="400"> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td width="30%">January</td> <td width="70%">$1000</td> </tr> <tr> <td>February</td> <td>1280</td> </tr> </table>Test and see ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the width attribute.
HTML5 The <td> width attribute is not supported. Please use CSS instead.
In HTML 4.01 In HTML, the <td> width attribute is deprecated.
The width attribute specifies the width of the table cell.
By default, cells will occupy the space required for their displayed content. The width attribute is used to set a predefined width for the cell.
In HTML 4.01 In the <td> width attribute is deprecated. Please use CSS instead.
CSS Syntax: <td style="width:100px">
CSS Example: Setting the width of table cells
In our CSS tutorial, you can find more about width attribute details.
<td width="pixels|%">
Value | Description |
---|---|
pixels | Set the width value in pixels (e.g., width="50"). |
percent | Set the width value as a percentage of the element's width (e.g., width="50%"). |