Changing the width of a table
Perhaps you wouldn't like the table to take up the whole
width of the browser window. Say you only wanted to take up 50% of the
browser window.
To make things a little less crowed let's go back to our first table
example and let's add the width attribute.
<body><table
width="50%" border="1"> <tr> <td>Text1 </td> </tr> </table></body>
|
The result would be:
As you can see the table has now reduced in half and only takes up half the
width of the browser. Keep in mind that by using a percent value the table will
take up 50% of the browser window. Therefore it may look very different in
two different browsers.
To make things more exact you can measure the
width of the table by using pixels. To do this, simply leave out the
percent sign, like so:
<body><table
width="100" border="1"> <tr> <td>Text1 </td> </tr> </table></body>
|
Now the table will look like this:
You can also set the height of a table, like so:
<body><table width="100"
height="100" border="1"> <tr> <td>Text1 </td> </tr> </table></body>
|
Now the table will look like this:
|