Colspan and row span in html



Col span means Merge the column  and row span means merge rows
in below example  3 column are merge.

Without Colspan

Output:

Student Detail
student detail
Student Name Roll Number Class
vinod 01 BSC
Mohit 02 BSC

1   Open notepad

2 write code and save 

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<table border="10" bordercolor="orange" bgcolor="cyan" cellpadding="5"">
<caption align=top>Student Detail</caption>


<tr> <td colspan="3"> student detail    </td> </tr>
<tr>
<th>Student Name</th>
<th>Roll Number</th>
<th>Class</th>
</tr>
<tr>
<td>vinod </td>
<td>01</td>
<td>BSC</td>
</tr>
<tr>
<td>Mohit </td>
<td>02</td>
<td>BSC</td>
</tr>
</table>
</body>
</html>

Output:


Student Detail
student detail
Student Name Roll Number Class
vinod 01 BSC
Mohit 02 BSC


ROW span:

Copy code and paste notepad then save
 the file .

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<table border="10" bordercolor="orange" bgcolor="cyan" cellpadding="5"">
<caption align=top>Student Detail</caption>

<tr> <td rowspan="4"> student detail    </td> </tr>
<tr>
<th>Student Name</th>
<th>Roll Number</th>
</tr>
<tr>
<td>vinod </td>
<td>01</td>
</tr>
<tr>
<td>Mohit </td>
<td>02</td>
</tr>
</table>
</body>
</html>

Output:


Student Detail
student detail
Student Name Roll Number
vinod 01
Mohit 02





Share this

Related Posts

Previous
Next Post »