How to use colspan and rowspan in HTML tables?

Spread the love

To use colspan and rowspan in HTML tables, we set the rowspan and colspan attributes.

For instance, we write

<table>
  <tbody>
    <tr>
      <td rowspan="2">LEFT</td>
      <td>1</td>
      <td>2</td>
      <td>3</td>
      <td>4</td>
      <td rowspan="2">RIGHT</td>
    </tr>
    <tr>
      <td>5</td>
      <td>6</td>
      <td>7</td>
      <td>8</td>
    </tr>
    <tr>
      <td>-</td>
      <td>-</td>
      <td>-</td>
      <td>-</td>
      <td>-</td>
      <td>-</td>
    </tr>
  </tbody>
</table>

to set the rowspan attribute to 2 to maker the td span 2 rows.

Leave a Reply

Your email address will not be published. Required fields are marked *