Split and merge tables in HTML (colspan, rowspan)

Split and merge tables in HTML (colspan, rowspan)

The code demonstrates horizontal merging:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Demonstration table tag 2--cell merging</title>
        <style type="text/css">
            td{
                text-align: center;
            }
        </style>
    </head>
    <body>
        <table border="1" cellspacing="0" width="50%" height="150">
            <caption>Merge cells horizontally</caption>
<!--colspan must specify the number of columns to be merged, whether it is two columns or three columns, etc.-->        
            <tr> <th colspan="2">Name and age</th> <th>Phone number</th> </tr>
            <tr> <td>Jack</td> <td>24</td> <td>1351234567</td> </tr>
            <tr> <td>Tom</td> <td>22</td> <td>1351234567</td> </tr>
            <tr> <td>Rose</td> <td>22</td> <td>1351234567</td> </tr>
            <tr> <td>张三</td> <td>25</td> <td>1351234567</td> </tr>
        </table>
        <br/>

        <table border="1" cellspacing="0" width="50%" height="150">

Running results:

這里寫圖片描述

The code demonstrates vertical merging:

<table border="1" cellspacing="0" width="50%" height="150">
            <caption>Merge cells vertically</caption>
            <tr><th>Class</t> <th>Name</th><th>Age</th> <th>Telephone</th> </tr>
            <tr><td rowspan="2">Class 601</td> <td>Jack</td> <td>24</td> <td>1351234567</td> </tr>
            <tr> <td>Tom</td> <td>22</td> <td>1351234567</td> </tr>
<!--rowspan must specify the number of columns to be merged, whether it is two rows or three rows, etc.-->    
            <tr><td rowspan="3">Class 602</td> <td>Rose</td> <td>22</td> <td>1351234567</td> </tr>
            <tr> <td>张三</td> <td>25</td> <td>1351234567</td> </tr>
            <tr> <td>Li Si</td> <td>25</td> <td>1351234567</td> </tr>
        </table>
    </body>
</html>

Running results:

這里寫圖片描述

This is the end of this article about table splitting and merging (colspan, rowspan) in HTML. For more related table splitting and merging content, please search 123WORDPRESS.COM's previous articles or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

<<:  Example code for implementing random roll caller in html

>>:  How to fix some content in a fixed position when scrolling HTML page

Recommend

Sample code for implementing horizontal infinite scrolling with pure CSS3

The examples in this article are all written in s...

Enabling or disabling GTID mode in MySQL online

Table of contents Basic Overview Enable GTID onli...

Detailed explanation of viewing and setting file permissions on Mac

Preface To modify file permissions in the termina...

How to solve the margin collapse problem in CSS

First, let's look at three situations where m...

Detailed explanation of MySQL multi-table join query

Table of contents Multi-table join query Inner Jo...

How to convert Chinese into UTF-8 in HTML

In HTML, the Chinese phrase “學好好學” can be express...

Vue and react in detail

Table of contents 1. Panorama II. Background 1. R...

Simple steps to configure Nginx reverse proxy with SSL

Preface A reverse proxy is a server that receives...

Docker container monitoring and log management implementation process analysis

When the scale of Docker deployment becomes large...

A brief discussion on the use of React.FC and React.Component

Table of contents 1. React.FC<> 2. class xx...

How to switch directories efficiently in Linux

When it comes to switching directories under Linu...

Vue+element implements drop-down menu with local search function example

need: The backend returns an array object, which ...

CSS3 to achieve menu hover effect

Result: html <nav id="nav-1"> <...

SQL ROW_NUMBER() and OVER() method case study

Syntax format: row_number() over(partition by gro...