Home > Web Front-end > HTML Tutorial > 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?

王林
Release: 2023-08-20 13:37:03
forward
1421 people have browsed it

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>
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template