" or "
Home > Article > Web Front-end > How to set the horizontal span of cells in html5
In HTML5, you can use the colspan attribute of the cell element (td or th) to set the horizontal span of the cell. This attribute can define the number of columns that the cell should span. The syntax "
" or " ". The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.
In HTML5, if you want to set the horizontal span of a cell, you can use the colspan attribute. (colspan attribute acts on td or th elements)
The colspan attribute is used to define the number of columns that the cell should span.
Syntax:
<td colspan="number"> <th colspan="number">
Value Description number specifies the number of columns the cell should span.
Comment:
colspan="0"
Tells the browser to make the cell span to the last column of the column group (colgroup).Example:
<!DOCTYPE <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>设置单元格列跨度</title> </head> <body> <table width="550" border="1" cellspacing="0" cellpadding="5"> <tr> <th colspan="2" align="center">存款(1~3月)</th> </tr> <tr> <td>一月</td> <td>3000 元</td> </tr> <tr> <td>二月</td> <td>5000 元</td> </tr> <tr> <td>三月</td> <td>3500 元</td> </tr> <tr> <td colspan="2">总计:11500 元</td> </tr> </table> </body> </html>Related recommendations: "html video tutorial"
The above is the detailed content of How to set the horizontal span of cells in html5. For more information, please follow other related articles on the PHP Chinese website!