Tuesday, December 31, 2013

Using Tables>>Table Col Span - (PART_26)

Topic:  I want a table where one of my row will have only 2 columns while others have 5 columns?  How to span the columns in html tables?

Explanation:

Col Span: While using table, it will be need of time that some of our rows should have lesser columns then others. It can be easily achieved by using colspan. 

For example I have a table with two rows and three colums. Now I want the first row to be of one column and the second to be of three columns.

Demo:
First Row
.
.
second Row
2
2
First Row
second Row
2
2
Table
Spanned Table



Here we have spanned one of the column to three columns. That is instead of adding three columns we will add only one column and span it using the attribute colspan="x". In this case as the column should be spanned to three we will be adding an attribute "colspan=3".
 

Tag:

<table>
<tr>
<td colspan=3>
First Row</td>
</tr>
<tr>
<td>
Second Row
</td>
<td >.</td>
<td>2</td>
</tr>
</table>