How to specify the number of columns a table cell should span in HTML?

HTMLWeb DevelopmentFront End Technology

Use the colspan attribute to set the number of columns a table cell should span. You can try to run the following code to implement colspan attribute −

<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
            border: 1px solid black;
         }
      </style>
   </head>
   <body>
      <h2>Total Marks</h2>
      <table>
         <th>Subject</th>
         <th>Marks</th>
         <tr>
            <td>Maths</td>
            <td>300</td>
         </tr>
         <tr>
            <td>Java</td>
            <td>450</td>
         </tr>
         <tr>
            <td colspan="2">Total Marks: 750</td>
         </tr>
      </table>
   </body>
</html>
raja
Published on 13-Mar-2018 12:09:04
Advertisements