table表格(实例):跨行跨列布局

这篇博客介绍了HTML中创建表格的基本元素,包括thead、tbody、tfoot、tr、td和th。同时,详细讲解了如何通过cellspacing和cellpadding设置单元格间距和内边距,以及使用border设定表格边框。此外,重点阐述了colspan和rowspan属性,用于实现单元格的跨列和跨行效果,以达到复杂布局的目的。

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

表格 table

表头 thead

表体 tbody

表尾 tfoot

行 tr

列 td

列 th

表格属性
cellspacing:  单元格与单元格之间的间距
cellpadding: 单元格的内边距
border: 1 表格边框大小
width: 表格宽度

单元格属性
colspan: 单元格跨列
rowspan: 单元格跨行

如图:

 

 
  <!-- 表格 -->
  <table border="1" cellspacing="0" cellpadding="10">

    <!-- 表头 -->
    <thead>
      <!-- 行 -->
      <tr>
        <th width="100">序号</th>
        <th width="100">地区</th>
        <th width="100">销售金额</th>
        <th width="100">备注</th>
      </tr>
    </thead>

    <!-- 表体 -->
    <tbody>
      <tr>
        <td>1</td>
        <td colspan="2">华北</td>
        <td>暂无</td>
      </tr>
      <tr>
          <td>2</td>
          <td rowspan="2" colspan="2">华南</td>
          <td>暂无</td>
        </tr>
        <tr>
            <td>3</td>
            <td>暂无</td>
          </tr>
    </tbody>

    <!-- 表脚 -->
    <tfoot>
      <tr>
        <td>12</td>
        <td>23</td>
        <td>4</td>
        <td>5</td>
      </tr>
    </tfoot>

  </table>

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值