HTML table width attribute
Examples
With 400 pixel width HTML table:
<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>
<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"
Browser Support
All major browsers support width attribute.
Definition and Usage
HTML5 does not support the <table> width attribute. Use CSS instead.
width attribute specifies the width of the table.
If you do not set the width property, the table space needed to display tabular data.
Tip: From a practical point of view, it is best not predetermined width, but the use of CSS to apply width (width) .
grammar
<table width="pixels|%">
Property Value
值 | 描述 |
---|---|
pixels | 设置以像素计的宽度(例子:width="50")。 |
% | 设置以包含元素的百分比计的宽度(例子:width="50%")。 |
HTML <table> tag