如何在 HTML 中包含表格列組?
使用 <colgroup> 標籤來包含表格列組。HTML <colgroup> 標籤用於指定表格內一組列的屬性。如果需要為列組內的列應用不同的屬性,可以在 <colgroup> 標籤內使用 HTML <col> 標籤。
以下是屬性:
| 屬性 | 值 | 描述 |
|---|---|---|
| Align | right left center justify char | 定義水平對齊方式,HTML5 中不支援。 |
| Char | 字元 | 定義用於對齊文字的字元(與 align ="char" 一起使用),HTML5 中不支援。 |
| Charoff | 畫素 | 定義 <col> 應跨越的列數,HTML5 中不支援。 |
| Span | 數字 | 定義 <col> 應跨越的列數,HTML5 中不支援。 |
| Valign | bottom middle top baseline | 定義垂直對齊方式,HTML5 中不支援。 |
Width | 畫素或 % | 指定當前 <col> 元素跨越的每一列的預設寬度,HTML5 中不支援。 |
示例
您可以嘗試執行以下程式碼在 HTML 中實現 <colgroup> 標籤:
<!DOCTYPE html> <html> <head> <title>HTML col Tag</title> </head> <body> <p>This example shows a colgroup that has three columns of different widths:</p> <table border = "1"> <colgroup span = "4"> <col width = "40"></col> <col width = "70"></col> <col width = "100"></col> <col width = "130"></col> <col width = "160"></col> </colgroup> <tr> <td>One</td> <td>Two</td> <td>Three</td> <td>Four</td> <td>Five</td> </tr> </table> </body> </html>
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP