表格标签

本文深入探讨了HTML中的表格元素,包括如何使用`<table>`,`<tr>`,`<td>`等标签创建和格式化表格,以及如何实现表格的复杂布局和数据交互。同时,还讨论了现代Web开发中表格的响应式设计和 Accessibility 问题。" 139609651,11390979,浮点与双精度累加精度分析——PLC轨迹规划影响,"['算法', 'PLC', '运动控制', '轨迹规划', '浮点计算']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

 

表格标签(很重要到一个标签)  

操作技巧:首先数数有多少行,然后数每一行有多少单元格。

 

一、格式 

<table  border="1" bordercolor="blue" cellspacing="0" width="400" height="150">      //表格的开始

       <caption>表格标题</caption>      //表格的标题,一般也不怎么写

  <tr align="center">                      //第一行。第一行所有单元格内容居中。

              <td> </td>                            //第一行的第一个单元格

              <td> </td>                            //第一行的第二个单元格

       </tr>

       <tr align="center">                       //第二行

         <td></td>

              <td></td>

       </tr>

       <tr align="center">                       //第三行

    <th></th>                             //可以使用th代替td,这时候会居中且加粗显示。

              <td></td>

       </tr>

</table>

 

<table>的属性:

border="1"                    //设置表格线的粗细。

bordercolor="blue"        //表格线的颜色

cellspacing="0"             //单元格与单元格之间距离为0。没有间隙了。

width="400"                 //表格的宽度

height="150"                //表格的高度

align="left"                  //整个表格居中显示。left 为居左 ,center 为居中,right为居右。

 

<tr>的属性:

align="center"              //内容对齐方式为:居中显示。left 为居左 ,center 为居中,right为居右。

 

<td>的属性:

align="right"                //本单元格的内容局右。

rowspan="3"                //这个单元格跨过3行。

colspan="3"                 //这个单元格跨过3列。

 

 

也可以使用<th></td>表示单元格,这时候会加粗并居中显示。

 

 

二、表格示例    

例题1:一般的表格 


//定义列表.html

<html>

        <head>

                <title>html示例</title>

        </head>

        <body>

                <table border="1" bordercolor="red" cellspacing="0" width="400" height="300">

                         <tr>                                                                                    //不用再写居中了。因为下面<th>标签自带居中和加粗。

                               <th>姓名</th>

                               <th>性别</th>  

                               <th>年龄</th>

                         </tr>

                         <tr align="center">

                               <td>东方不败</td> 

                               <td>男</td>  

                               <td>20</td>

                         </tr>

                         <tr align="center">

                               <td>岳不群</td>

                               <td>女</td>

                               <td>30</td>

                         </tr>

                         <tr align="center">

                               <td>林平之</td>

                               <td>男</td> 

                               <td>40</td>

                         </tr>

                </table>

        </body>

 

</html>

 

 

例题2:合并的单元格 

 

 

//定义列表.html

<html>

        <head>

                <title>html示例</title>

        </head>

        <body>

                <table border="1" bordercolor="red" cellspacing="0" width="400" height="300">

                         <tr>                                                                              

                               <td colspan="3">人员信息</td>            //第一行第一个单元格跨3列。

                         </tr>

                         <tr align="center">

                               <td>东方不败</td> 

                               <td>男</td>  

                               <td>20</td>

                         </tr>

                         <tr align="center">

                               <td>岳不群</td>

                               <td>女</td>

                               <td>30</td>

                         </tr>

                         <tr align="center">

                               <td>林平之</td>

                               <td>男</td> 

                               <td>40</td>

                         </tr>

                </table>

        </body>

 

</html>

 

例题3:合并的单元格 

 

 

分析:共有三行三列。

第一行:3个单元格。

第二行:2个单元格。

第三行:2个单元格。

 

//定义列表.html

<html>

        <head>

                <title>html示例</title>

        </head>

        <body>

                <table border="1" bordercolor="red" cellspacing="0" width="400" height="300">

                         <tr align="center">

                               <td>东方不败</td> 

                               <td>男</td>  

                               <td rowspan="3">20</td>              //第一行第3个单元格跨3行。

                         </tr>

                         <tr align="center">

                               <td>岳不群</td>

                               <td>女</td>

                         </tr>

                         <tr align="center">

                               <td>林平之</td>

                               <td>男</td> 

                         </tr>

                </table>

        </body>

 

</html>

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值