<html> <head> <script type="text/javascript"> function padding() { document.getElementById('myTable').cellPadding="15"; } function spacing() { document.getElementById('myTable').cellSpacing="15"; } </script> </head> <body> <table id="myTable" border="1"> <tr> <td>100</td> <td>200</td> </tr> <tr> <td>300</td> <td>400</td> </tr> </table> <br /> <input type="button" onclick="padding()" value="Change Cellpadding"> <input type="button" onclick="spacing()" value="Change Cellspacing"> </body> </html>
Your Result:
Edit the code above and click to see the result.
W3Schools.com
- Try it yourself