在 HTML 中,嵌套表格是指在同一个网页上的一个表格内创建另一个表格。

注意:内部表格必须始终放置在外部表格的 <td> ... </td> 之间。

示例:以下示例演示如何创建嵌套表格。在此示例中,我们创建一个表格,其中在第一行的第二个单元格内包含另一个表格。

<!DOCTYPE html>
<html>
<head>
<title>Example of Nested Table</title>
</head>
<body>
<!-- 使用 table 标签在网页上创建外部表格。
此 table 标签包含两个属性 border 和 bordercolor。
border 属性用于指定外部表格的边框(4),bordercolor 用于指定外部表格边框的绿色。 -->
<table border="4" bordercolor="green">
<tr>
<td>It is a 1st Cell of 1st row in the 1st Table.</td>
<td>It is a 2nd Cell of 1st row in the 1st Table.
<!-- 使用 table 标签创建一个内部表格,该表格显示在外部表格的第一行的第二个单元格中。
此 table 标签也包含两个属性 border 和 bordercolor。
border 属性用于指定内部表格的边框(6),bordercolor 用于指定内部表格边框的蓝色。 -->
<table border="6" bordercolor="blue">
<tr>
<td>It is a 1st Cell of 1st row in the 2nd Table.</td>
</tr>
<tr>
<td>It is a 2nd Cell of 2nd row in the 2nd Table.</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>It is a 3rd Cell of 2nd row in the 1st Table.</td>
<td>It is a 4th Cell of 2nd row in the 1st Table.</td>
</tr>
</table>
</body>
</html>

输出:

1.png

浏览器支持

元素chrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
嵌套表格

标签: html, HTML教程, HTML技术, HTML学习, HTML学习教程, HTML下载, HTML语言, HTML开发, HTML入门教程, HTML进阶教程, HTML面试题, HTML笔试题, HTML编程思想