How to set the horizontal span of cells in html5

青灯夜游
Release: 2021-12-17 16:38:48
Original
2602 people have browsed it

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 " ".

How to set the horizontal span of cells in html5

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">
Copy after login
ValueDescription
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>
Copy after login

How to set the horizontal span of cells in html5

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!