Sams Teach Yourself HTML 4 in 24 Hours

Sams Teach Yourself HTML 4 in 24 Hours

By Dick Oliver

Table Size

Ordinarily, the size of a table and its individual cells automatically expand to fit the data you place into it. However, you can choose to control the exact size of the entire table by putting width and/or height attributes in the <table> tag. You can also control the size of each cell by putting width and height attributes in the individual <td> tags. The width and height can be specified as either pixels or percentages. For example, the following HTML makes a table 500 pixels wide and 400 pixels high:

<table width="500" height="400">

To make the first cell of the table 20 percent of the total table width and the second cell 80 percent of the table width, you would type the following:

<table><tr><td width="20%">skinny cell</td>
<td width="80%">fat cell</td></tr></table>

When you use percentages instead of fixed pixel sizes, the table will resize automatically to fit any size browser window, while maintaining the aesthetic balance you're after.

Share ThisShare This

Informit Network