HTML <table> width attribute
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!
|
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
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> tag
…
|