HTML&CSS 高级表格 合并单元格

有时,需要合并单元格,即有的元素占用两行,有的元素占用两列。这时,用到了以下XHTML属性:

rowspan

colspan

一个简单的例子:

HTML代码如下:

Date Event Details Contact
Event Description Approximate Cost
12 July Committee meeting, deciding on next year's trips N/A Bob Dobalina
19 July 7-day trip to Hurghada (package deal) - limited spaces £260 pp (all inclusive), departing Luton Bob Dobalina
5 August Ocean & Sports Diver Theory Course Call for details Jeff Edgely
12 August Murder Mystery Weekend, Cotswolds (no diving!) £65 pp (accommodation included) Jill Smith



CSS代码如下:

table {
        border-collapse: collapse;   
        border: 1px solid black; 
      }  
      th {
        text-align: left;
        border: 1px solid black;
        padding: 0.2em;
      }
      td {
        border: 1px solid black;
        padding: 0.2em;
      }



你可能感兴趣的:(HTML&CSS)