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

HTML Reference Manual

HTML Tag大全

HTML: <th> width attribute

<th>Usage of the width attribute, width specifies the width of the header cell, an online instance demonstrates how to use the <th> width attribute, browser compatibility, syntax definition, and detailed information about its attribute values, etc.</th>

 HTML <th> etichetta

Online example

Table header cells with predefined width:

<table style="width:100%" border="1">
  <tr>
    <th width="70%">Year</th>
    <th width="30%">Savings</th>
  </tr>
  <tr>
    <td>2019</td>
    <td>80000 Yuan</td>
  </tr>
  <tr>
    <td>2018</td>
    <td>70000 Yuan</td>
  </tr>
</table>
Test and see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

Tutti i browser mainstream supportano l'attributo width.

Definizione e uso

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

In HTML 4.01, l'attributo width di <th> è deprecato.

L'attributo width specifica la larghezza della cella di intestazione.

Di solito, lo spazio occupato dalla cella è uguale allo spazio necessario per il contenuto visualizzato. L'attributo width viene utilizzato per impostare una larghezza predefinita per la cella.

Commenti di compatibilità

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

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

CSS Esempio: Imposta la larghezza della cella di intestazione

Nel nostro tutorial CSS, puoi trovare ulteriori informazioni suProprietà width dettagli.

Sintassi

<th width="pixels|%">

Valore dell'attributo

ValoreDescrizione
pixelsImposta il valore della larghezza in pixel (ad esempio width="50").
%Imposta il valore della larghezza come percentuale dell'elemento (ad esempio width="50%").
 HTML <th> etichetta