merge cells in html table code example

Example 1: concatenate cells in table html

<table>
  <tr>
    <th> Name </th>
    <th> Qty </th>
    <th> Unit Price </th>
    <th> Cost </th>
  </tr>
  <tr>
    <td> Pencil </td>
    <td> 2 </td>
    <td> 2.50 </td>
    <td> 5.00 </td>
  </tr>
  <tr>
    <td> Handle </td>
    <td> 4 </td>
    <td> 3.50 </td>
    <td> 14.00 </td>
  </tr>
  <tr>
    <td colspan = "3"> Total </td>
    <td> 19.00 </td>
  </tr>
</table>

Example 2: html table span 2 rows

<td colspan="2">Content here</td> // or...
<td rowspan="2">Content here</td>

Example 3: html table colspan and rowspan

<td colspan="4">Content</td>
<td rowspan="4">Content</td>

Tags:

Html Example