![]() |
|
Advanced HTML Tables 2, Free online HTML Tutorial, Learn HTML online for free... |
| Lessons | Advanced HTML Tables |
|
||||||||
|
Next we are going to discuss how HTML controls the contents of cells. First of all we will see how we can align the content of our cells. align="" This attribute sets the background color of a single cell if used with <td> and it sets the background color of the whole row if it is used with <tr>. It can take the color value as Hex or one of the color names available here. <table cellspacing="2" cellpadding="3" border="5" width="100%">
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td align="left">Mr. A--Left aligned</td>
<td align="right">10 Years--Right aligned</td>
</tr>
<tr>
<td align="center">Mr. B--Centered</td>
<td bgcolor="pink">20 Years</td>
</tr>
<tr bgcolor="#FF0000">
<td>Mr. Z</td>
<td>60 Years</td>
</tr>
</table>
This HTML will be displayed as:
Table Nesting: Tables can also be nested by adding <table> and </table> tags within <td> and </td> tags of the enclosing <table>. <table> <tr> <td> <table> <tr><td>first nested table</td></tr></table> </td> <td> <table><tr><td>second nested table</td></tr></table> </td> </tr> <table>You can make your tables as complicated as you want. But remember to make them as complex as you can easily handle.
Next >>> Lesson No. 19: Relative and Absolute Paths
|