colspan 讓單元格橫跨多欄,是製作複雜表頭、合併儲存格的關鍵屬性。
<td colspan="2">跨兩欄的標題</td>
<th colspan="3">跨三欄的表頭</th>
<td>/<th> 數量減少<table border="3" width="400" bordercolor="#336699" align="center">
<tr>
<td colspan="2" align="center">網頁製作軟體</td>
</tr>
<tr>
<td>網頁圖像軟體</td><td>Fireworks</td>
</tr>
<tr>
<td>網頁製作軟體</td><td>Dreamweaver</td>
</tr>
<tr>
<td>網頁動畫軟體</td><td>Flash</td>
</tr>
</table>
第一列單一儲存格跨兩欄,作為分類標題;後續各列兩欄正常顯示。
<table>
<thead>
<tr>
<th rowspan="2">學期</th>
<th colspan="2">期中考</th>
<th colspan="2">期末考</th>
</tr>
<tr>
<th>國文</th><th>數學</th>
<th>國文</th><th>數學</th>
</tr>
</thead>
<tbody>...</tbody>
</table>
結合 rowspan(跨列)與 colspan(跨欄)構建多層級表頭。
/* 僅視覺合併,語義結構不變,無障礙較差 */
td.merge-right { border-right: none; }
td.merge-left { border-left: none; }
強烈建議:真正的跨欄數據必須用 colspan,確保螢幕閱讀器正確宣告欄位關聯。