Home  >  Article  >  Web Front-end  >  How to specify in HTML the number of columns a table cell should span?

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

王林
王林forward
2023-08-20 13:37:031333browse

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

Use the colspan property to set the number of columns that table cells should span. You can try running the following code to achieve colspan property−

<!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>

The above is the detailed content of How to specify in HTML the number of columns a table cell should span?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete