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

Vue+axios sample code for uploading pictures and recognizing faces

Table of contents Axios Request Qs processing dat...

A brief analysis of JS original value and reference value issues

Primitive values ​​-> primitive types Number S...

Master the CSS property display:flow-root declaration in one article

byzhangxinxu from https://www.zhangxinxu.com/word...

Pure JavaScript to implement the number guessing game

Develop a number guessing game that randomly sele...

How to modify the group to which a user belongs in Linux

Modify the group to which a user belongs in Linux...

How to View All Running Processes in Linux

You can use the ps command. It can display releva...

Summary of web designers' experience and skills in learning web design

As the company's influence grows and its prod...

CSS inheritance method

Given a div with the following background image: ...

Examples of using the or statement in MySQL

1. The use of or syntax in MySQL, and the points ...

CSS achieves the effect of two elements blending (sticky effect)

I remember that a few years ago, there was an int...

React's method of realizing secondary linkage

This article shares the specific code of React to...

Three useful codes to make visitors remember your website

Three useful codes to help visitors remember your...

MySQL 5.7.23 version installation tutorial and configuration method

It took me three hours to install MySQL myself. E...