HTML table cross-row and cross-column operations (rowspan, colspan)

HTML table cross-row and cross-column operations (rowspan, colspan)

Generally, the colspan attribute of the <td> element is used to implement cell cross-column operations, and the rowspan attribute of the <td> element is used to implement cell cross-row operations.

The colspan attribute specifies the number of columns a cell can span. All browsers support the colspan attribute. Its value is number, as shown in the following figure:

For example:

<table border="1">
  <tr>
    <th>Monday</th>
    <th>Tuesday</th>
  </tr>
  <tr>
    <td colspan="2">Sunday</td>
  </tr>
</table>

The implementation result is shown in the figure below:

The rowspan attribute specifies the number of columns a cell can span. All browsers support the rowspan attribute. Its value is number, as shown in the following figure:

For example:

<table border="1">
  <tr>
    <td rowspan="2">Monday</td>
    <td>Tuesday</td>
  </tr>
  <tr>
    <td>Wednesday</td>
  </tr>
</table>

The implementation result is shown in the figure below:

The use of colspan and rowspan is summarized as follows:

<table border="1">
  <tr>
    <th colspan="3">Material Details</th>
  </tr>
  <tr>
    <td colspan="2" align="center">Quantity (pieces)</td>
    <td rowspan="2">Weight (tons)</td>
  </tr>
  <tr>
    <td>Actual number of issuances</td>    
    <td>Actual amount collected</td>
  </tr>
  <tr>
    <td>12</td>    
    <td>10</td>
    <td>100.00</td>
  </tr>
</table>

The implementation result is shown in the figure below:

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

<<:  Implementation of Single Div drawing techniques in CSS

>>:  How to import CSS styles into HTML external style sheets

Recommend

Why MySQL does not recommend using subqueries and joins

To do a paginated query: 1. For MySQL, it is not ...

Share 16 burning flame effect English fonts treasure trove

We live in a visual world and are surrounded by m...

The difference between br and br/ in HTML

answer from stackflow: Simply <br> is suffic...

Summary of basic usage of $ symbol in Linux

Linux version: CentOS 7 [root@azfdbdfsdf230lqdg1b...

How to view MySQL links and kill abnormal links

Preface: During database operation and maintenanc...

Four ways to compare JavaScript objects

Table of contents Preface Reference Comparison Ma...

Detailed explanation of commands to view linux files

How to view linux files Command to view file cont...

How to run .sh files in Linux system

There are two ways to run .sh files in Linux syst...

JavaScript prototype and prototype chain details

Table of contents 1. prototype (explicit prototyp...

Example of pre-rendering method for Vue single page application

Table of contents Preface vue-cli 2.0 version vue...

A brief discussion on MySQL event planning tasks

1. Check whether event is enabled show variables ...

A brief discussion on how to customize the host file in Docker

Table of contents 1. Command 2. docker-compose.ym...

Use JS to zoom in and out when you put the mouse on the image

Use JS to zoom in and out when the mouse is on th...