Table width : Table Layout « Table « JavaScript DHTML

Table width

<script language="JavaScript">
    function function1() {
        document.getElementById("myTable").width = "300";
    function function2() {
        document.getElementById("myTable").width = "500";
<table id="myTable" cols="3" border="3" cellspacing="5" cellpadding="5">
    <script language="JavaScript">
        document.getElementById("myTable").width = 500;
        <th>Column 1</th>
        <th>Column 2</th>
        <th>Column 3</th>
        <td>Cell 1</td>
        <td>Cell 2</td>
        <td>Cell 3</td>
<input type="button" value="Change table width to 300px" onClick="function1();">
<input type="button" value="Restore table width to 500px" onClick="function2();">

Related examples in the same category

1.Table rules
2.Table frame
3.Table cell padding and space Example