Computer >> Computer tutorials >  >> Programming >> HTML

What are table rowspan and colspan in HTML?


The rowspan and colspan are <td> tag attributes. These are used to specify the number of rows or columns a cell should span. The rowspan attribute is for rows as well as the colspan attribute is for columns.

What are table rowspan and colspan in HTML?

These attributes have numeric values, for example, colspan=3 will span three columns.
You can try to run the following code to work with the rowspan and colspan attribute in HTML

Example

<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="3"></td>
         </tr>
         <tr>
            <td></td>
            <td></td>
         </tr>
         <tr>
            <td></td>
            <td></td>
         </tr>
      </table>
   </body>
</html>

Output

What are table rowspan and colspan in HTML?