|
If you have created a basic table in HTML you will notice that the size of the table and it's cells are
determined by the text of images in those cells.
| Let's put a sentence in this cell |
A |
| B |
HTML is fun |
See how the size of the cells and the table itself are determined by what data is in the table.
By using WIDTH in our HTML code we can control the size of the cells and the table.
| Let's put a sentence in this cell |
A |
| B |
HTML is fun |
There are two ways that you can define the table width and cell width. One way is to define the width as a percentage the other is to define the width in pixels.
In our example above we defined the table width as a percentage of 85% space available.
|
<Table border="1" Cellspacing="1" Cellpadding="5" WIDTH="85%">
<TR Align="center">
<TD width="60%"> Let's put a sentence in this cell </TD>
<TD width="40%"> A </TD>
</TR>
<TR Align="center">
<TD> B </TD>
<TD> HTML is fun </TD>
</TR>
</TABLE>
|
Also, we assigned widths to our columns as a percentage of the table size in or TD tag
<TD width="60%"> <TD width="40%">
If you wish you can set the size of the table and / or the cells in pixels as we did with this example;
| Let's put a sentence in this cell |
A |
| B |
HTML is fun |
|
<Table border="1" Cellspacing="1" Cellpadding="5" WIDTH="500">
<TR Align="center">
<TD width="300%"> Let's put a sentence in this cell </TD>
<TD width="200%"> A </TD>
</TR>
<TR Align="center">
<TD> D </TD>
<TD> HTML is fun </TD>
</TR>
</TABLE>
|
|