How to set the number of rows a table cell should span in HTML?


Use the rowspan attribute to set the number of rows a table cell should span. To merge cells in HTML, use the colspan and rowspan attribute. The rowspan attribute is for number of rows a cell should span, whereas the colspan attribute is for number of columns a cell should span.

Example

<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
            border: 1px solid black;
            width: 100px;
            height: 50px;
         }
      </style>
   </head>

   <body>
      <h1>Heading</h1>
      <table>
         <tr>
            <th colspan = "2"></th>
            <th></th>
         </tr>
         <tr>
            <td></td>
            <td></td>
            <td rowspan = "2"></td>
         </tr>
         <tr>
            <td></td>
            <td></td>
         </tr>
      </table>
   </body>
</html>

Updated on: 01-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements