HTML <table> widthAttribute

HTML table 标签参考手册HTML <table> tag

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>

Try it yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the width attribute.


Definition and Usage

HTML5 does not support the <table> width attribute. Use CSS instead.

The width attribute specifies the width of a table.

If the width attribute is not set, the table takes up the space it needs to display the table data.

Tip:From a practical standpoint, it is better not to specify the width, but to use CSS to applywidth (width)。


Syntax

<table width="pixels|%">

Attribute Values

Value Description
pixels Sets the width in pixels (example: width="50").
% Sets the width as a percentage of the containing element (example: width="50%").


HTML table 标签参考手册HTML <table> tag Other Extensions