HTML Lessons  

  1. HTML Introduction

  2. HTML Tags

  3. HTML Page Structure

  4. HTML Backgrounds

  5. HTML Formatting Text

  6. HTML Formatting Fonts

  7. HTML Headings

  8. HTML Entities

  9. HTML Line Breaks

  10. HTML Lists

  11. HTML HR- Horizontal Rule

  12. HTML Images

  13. HTML Links

  14. Table Introduction

  15. Table Rows & Columns

  16. Table Width

  17. Table Alignment

  18. Table Border Color

  19. Table Background Color

  20. Table Background Image

  21. Cell Alignment

  22. Cell Padding

  23. Cell Spacing

  24. Cell Spanning

 

Spanning Cells

Two very useful cell attributes are the rowspan and colspan attributes. These allow any given cell to span more than one row or one column.

I know.  That sounds a little confusing.  Let's look at the example below.

<body>
<table border="1">
<tr>
<td colspan="2">Text1 </td>
</tr>
<tr>
<td>Text2</td>
<td>Text3</td>
</tr>
</table>
</body>

Text1
Text2 Text3

Notice how the first row  only has one cell tag in the code <td>.  Also notice how there is only one cell in the first row of the table that has spanned over two columns.

You can have the cell span over more columns if you like.  Let's try to span it over 3 columns.

<body>
<table border="1">
<tr>
<td colspan="3">Text1 </td>
</tr>
<tr>
<td>Text2</td>
<td>Text3</td>
<td>Text4</td>
</tr>
</table>
</body>

Text1
Text2 Text3 Text4

If you wanted the cell to span over three rows instead of three columns you'd use the rowspan attribute.

<body>
<table border="1">
<tr>
<td rowspan="2">Text1 </td>
<td>Text2</td>
</tr>
<tr>
<td>Text3</td>
</tr>
</table>
</body>

Text1 Text2
Text3

To span it over 3 columns...

<body>
<table border="1">
<tr>
<td rowspan="3">Text1 </td>
<td>Text2</td>
</tr>
<tr>
<td>Text3</td>
</tr>
<tr>
<td>Text4</td>
</tr>
</table>
</body>

Text1 Text2
Text3
Text4

© Copyright Studio6000 2006. All rights Reserved.