四、HTML中表格的书写

一、表格的标签
    <table>:表格的最外层容器
    <th>: 定义表头
    <tr> : 定义表格行
    <td>: 定义表格单元
    <caption>:定义表格标题    
二、表格的属性
    border : 表格边框
    cellpadding : 单元格内的空间
    cellspacing : 单元格之间的空间
    rowspan : 合并行(上下合并)
    colspan : 合并列(左右合并)
    align : 左右对齐方式 ( left center right )
    valign :上下对齐方式 ( top middle bottom )
    width、height : 表格的宽高
表格例子:
1     <table border="1" cellpadding="30" cellspacing="30"> 
2         <tr>
3             <th align="right" width="300">日期</th>
4             <th colspan="2">天气</th>
5             <th>出行情况</th>
6         </tr>
7     </table>
三、语义化标签:
<thead>、<tbody>、<tfoot> 
并不会对表格产生任何影响,语义化更好。
一个表格table中,只能有一个thead和tfoot,但是可以有多个tbody
 1 <table border="1" cellpadding="30" cellspacing="30"> 
 2     <thead>
 3         tr>
 4             <th colspan="4">出行情况</th>
 5         </tr>
 6     </thead>
 7     <tbody>
 8         <tr>
 9             <th align="right" width="300">日期</th>
10             <th colspan="2">天气</th>
11             <th>出行情况</th>
12         </tr>
13     </tbody>
14     <tfoot>
15         <tr>
16             <th align="right" width="300">日期</th>
17             <th colspan="2">天气</th>
18             <th>这是结尾</th>
19         </tr>
20     </tfoot>
21 </table>

 

注:表格也是有嵌套规范的。
posted @ 2020-02-20 09:45  不懂老爱瞎逼逼  阅读(441)  评论(0编辑  收藏  举报