CreateaFreeWebsite  with Responsive Web Design

Tables and Rowspan

Rowspan is a feature of HTML that is useful when we want a column in a multiple row table to extend downward into the next row.

When used properly with the colspan attribute, we can create some interesting table layouts for our data.

2 Row 2 Column Table

In this example notice than only one column definition is provided on the second row. The first column on the second row is treated as if it doesn't exist, because column 1 on row 1 occupies its position.

 

The rain in spain falls mainly on the plain
Row 1 Column 1 (Rowspan=2)

The rain in spain falls mainly on the plain
Row 1 Column 2 (Rowspan=1)

The rain in spain falls mainly on the plain
Row 2 Column 1 (Rowspan=1)

 

HTML

<table class="demo1">
<tr>
<td colspan="1" rowspan="2"></td>
<td colspan="1" rowspan="1"></td>
</tr>
<tr>
<td colspan="1" rowspan="1">
</td></tr></table>

CSS

table.demo1 {
max-width: 100%;
margin: 0 auto}
td  {
vertical-align: top; 
padding: 10px;
border: solid #000000 2px
}

 

2 Row 3 Column Table

This example shows a 2 row 3 column table.

Because the first column on the first row spans into what would be the first column on the second row, only one column definition is used on the second row.

The third column definition on the second row is omitted because we want the one existing column to be 2 columns wide.

Clear as MUD! I know, but check the code.

 

The rain in spain falls mainly on the plain
Row 1 Column 1 Rowsp=2

The rain in spain falls mainly on the plain
Row 1 Column 2 Rowsp=1

The rain in spain falls mainly on the plain
Row 1 Column 3 Rowsp=1

The rain in spain falls mainly on the plain
Row 2 Column 1 Rowsp=1

 

The HTML without text same CSS:

<table class="demo1">
<tr>
<td colspan="1" rowspan="2" style="background:#78B0DA"></td>
<td colspan="1" rowspan="1"></td>
<td colspan="1" rowspan="1" style="background:#FF8080"></td>
</tr>
<tr>
<td colspan="2" rowspan="1"></td>
</tr></table>

 

Free Tools We Recommend

Free Ebook How to Code in HTML5 and CSS3
"How to Code in HTML5 and CSS3" is a free e-book about making websites in HTML5 and CSS for absolute beginners. It doesn't require any experience in IT to start....
FREE HTML Editor (Windows): NoteTab Light
All the features of a commercial HTML editor.
FREE Apache Server (Windows): IndigoAmpp
Set up a real time server environment right on your PC. Test forms and scripts before uploading to your web space.
Linux Users
If like us, you've left the insane world of Microsoft Windows for the even worse experience of Linux, we recommend the Geany Code Editor. You'll find it in your Linux Mint software repository. It's simple but powerful and FREE.
For image resizing we've found the easiest Linux tool to be Krita.

Have you tried out RWD template kit? Download Template #402 - 6 Page Kit