width 属性可设置或返回表格的宽度。
tableObject.width=percent|pixels
下面的例子可更改表格的宽度:
<html>
<head>
<script type="text/javascript">
function changeWidth()
{
document.getElementById("table1").width="100%";
}
</script>
</head>
<body>
<table id="table1" border="1">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
</table>
<br />
<input type="button" onclick=changeWidth()
value="Change table width" />
</body>
</html>