Thuộc tính colspan <th> HTML

❮ Thẻ HTML <th>

Thí dụ

Một bảng HTML có ô tiêu đề kéo dài hai cột:

<table>
  <tr>
    <th colspan="2">Monthly Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>

Định nghĩa và Cách sử dụng

Thuộc colspantính xác định số cột mà một ô tiêu đề sẽ kéo dài.


Hỗ trợ trình duyệt

Attribute
colspan Yes Yes Yes Yes Yes

Lưu ý: Chỉ Firefox mới hỗ trợ colspan="0", điều này có ý nghĩa đặc biệt (xem bên dưới trong bảng "Giá trị thuộc tính").


Cú pháp

<th colspan="number">

Giá trị thuộc tính

Value Description
number Sets the number of columns a header cell should span. Note: colspan="0" tells the browser to span the cell to the last column of the column group (colgroup)

❮ Thẻ HTML <th>