在HTML文档中,广泛使用表格来存放网页上的文本和图像进行布局
语法:
<table border="1"> 1表示1像素px
<tr>
<td>单元格内容</td>
</tr>
... ...
</table>
<html> <meta charset="UTF-8"> <head> <title>列表</title> </head> <body> <table border="1px" cellspacing="0px" cellpadding="5px"> <tr> <td><a href="#">1行1列的单元格</a></td> <td>1行2列的单元格</td> <td>1行3列的单元格</td> </tr> <tr> <td>2行1列的单元格</td> <td>2行2列的单元格</td> <td>2行3列的单元格</td> </tr> <tr> <td>3行1列的单元格</td> <td>3行2列的单元格</td> <td>3行3列的单元格</td> </tr> </table> <hr/> <table border="1px" cellspacing="0px" cellpadding="0px"> <tr> <!--colspan跨列--> <td colspan="2">学生成绩</td> </tr> <tr> <td>语文</td> <td>98</td> </tr> <tr> <td>数学</td> <td>95</td> </tr> </table> <hr/> <table border="2px" cellspacing="0px" cellpadding="5px" height="100px" width="280px"> <tr> <td rowspan="2">张三</td> <td>语文</td> <td>98</td> </tr> <tr> <td>数学</td> <td>95</td> </tr> <tr> <td rowspan="2">李四</td> <td>语文</td> <td>98</td> </tr> <tr> <td>数学</td> <td>95</td> </tr> </table> </body> </html>
table练习
代码:
<html> <meta charset="UTF-8"> <head> <title>table练习</title> </head> <body> <table border="1px" cellspacing="0px" cellpadding="5px" height="100px" width="300px"> <tr> <td color="blue"><font color="blue">手机充值、IP卡</font></td> <td colspan="3"><font color="blue">办公设备、文具、耗材</font></td> </tr> <tr> <td rowspan="3">各种卡的总汇</td> <td>铅笔</td> <td>彩笔</td> <td>粉笔</td> </tr> <tr> <td>打印</td> <td>刻录</td> <td>墨盒</td> </tr> <tr> <td>笔记</td> <td>钢笔</td> <td>墨水</td> </tr> </table> </body> </html>
时间: 2024-10-12 03:57:30