How to have a table cell that spans two columns in HTML?

 Posted by Pgayath on 9/21/2012 | Category: HTML 5 Interview questions | Views: 1465 | Points: 40
Answer:

The <colspan> tag inside a <th> or <td> tag is used to span the columns.
Let us see an example.

Example:
<html>

<body>

<h4>Cell that spans two columns:</h4>
<table border="1">
<tr>
<th>Name</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<td>Charles Babbage</td>
<td>555 89 123</td>
<td>555 98 321</td>
</tr>
</table>
</body>
</html>


| Alert Moderator 

Comments or Responses

Login to post response