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

HTML Reference Manual

HTML Tag Encyclopedia

HTML Table Width Attribute

The HTML table width attribute specifies the width of the table. If the width attribute is not set, the table will occupy the space required to display the table data.

 HTML <table> tag

Online Example

With 300 Pixel-width HTML Table:

<table width="300" border="1">
  <tr>
    <th>Name</th>
    <th>Credits</th>
  </tr>
  <tr>
    <td>Zhang San</td>
    <td>90</td>
  </tr>
  <tr>
    <td>Li Si</td>
    <td>87</td>
  </tr>
</table>
Test See </›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the width attribute.

Definition and Usage

HTML5 The <table> width attribute is not supported. Please use CSS instead.

The width attribute specifies the width of the table.

If the width attribute is not set, the table will occupy the necessary space to display the table data.

Tip:For practical purposes, it is best not to specify the width and use CSS to apply width (width)

Syntax

<table width="pixels|%">

Attribute Value

ValueDescription
pixelsSet the width in pixels (example: width="50")。
%Set the width of the element as a percentage (example: width="50%")。
 HTML <table> tag