Latest

recent

HTML table width attribute

Example

An HTML table with a width of 400 pixels:
<table border="1" width="400">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>


Definition and Usage

The width attribute specifies the width of a table.
If the width attribute is not set, a table takes up the space it needs to display the table data.
For practical reasons, it may be better not to specify the width, and use CSS to apply the width instead.

Browser Support

The width attribute is supported in all major browsers.

Syntax

<table width="value">

Attribute Values

Value Description
pixels Sets the width in pixels (example: width="50")
percent Sets the width in percent of the surrounding element (example: width="50%")
HTML table width attribute Reviewed by 1000sourcecodes on 02:21 Rating: 5
Powered by Blogger.