English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML reference manual

HTML tag大全

HTML td width attribute

The width attribute specifies the width of the table cell. By default, the cell takes up the space required for its display content. The width attribute is used to set the predefined width of the cell.

 HTML <td> etichetta

Online example

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 ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

Tutti i browser principali supportano l'attributo width.

Definizione e uso

HTML5 non supporta l'attributo width di <td>. Usa CSS invece.

In HTML 4.01, l'attributo width di <td> è obsoleto.

L'attributo width specifica la larghezza della cella della tabella.

Di solito, le celle occupano lo spazio necessario per il loro contenuto visualizzato. L'attributo width viene utilizzato per impostare la larghezza predefinita delle celle.

Commenti di compatibilità

In HTML 4.01, l'attributo width di <td> è obsoleto. Usa CSS invece.

Sintassi CSS: <td style="width:100px">

Esempio CSS: Imposta la larghezza della cella della tabella

Nel nostro tutorial CSS, puoi trovare ulteriori informazioni su Attributo width dettagli.

Sintassi

<td width="pixel|%">

Valore dell'attributo

ValoreDescrizione
pixelImposta un valore di larghezza in pixel (ad esempio width="50").
percentoImposta un valore di larghezza in percentuale per l'elemento (ad esempio width="50%").
 HTML <td> etichetta