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

Our thoughts on the UI engineer career

I have been depressed for a long time, why? Some t...

Detailed tutorial on installation and configuration of nginx under Centos7

Note: The basic directory path for software insta...

Let's talk about the difference between containers and images in Docker

What is a mirror? An image can be seen as a file ...

The connection between JavaScript constructors and prototypes

Table of contents 1. Constructors and prototypes ...

How to configure virtual user login in vsftpd

yum install vsftpd [root@localhost etc]# yum -y i...

Solve the error of installing VMware Tools on Ubuntu 18.04

1. According to the online tutorial, the installa...

Analysis of the cause of docker error Exited (1) 4 minutes ago

Docker error 1. Check the cause docker logs nexus...

Springboot+Vue-Cropper realizes the effect of avatar cutting and uploading

Use the Vue-Cropper component to upload avatars. ...

Native JS realizes compound motion of various motions

This article shares with you a compound motion im...

How to install MySQL 8.0 and log in to MySQL on MacOS

Follow the official tutorial, download the instal...

Setting up VMware vSphere in VMware Workstation (Graphic Tutorial)

VMware vSphere is the industry's leading and ...

Solve the problem of managing containers with Docker Compose

In Docker's design, a container runs only one...

Analysis of the differences between Iframe and FRAME

1. Use of Iframe tag <br />When it comes to ...