如何在 HTML 中為表格列新增屬性?
使用 <col> 標籤為表格列新增屬性。HTML <col> 標籤允許作者將表格列的屬性規範組合在一起。它不會在結構上將列組合在一起——這是 <colgroup> 元素的作用。
以下是屬性:
| 屬性 | 值 | 描述 |
|---|---|---|
| Align | right left center justify char | 定義水平對齊方式,HTML5 中不支援。 |
| Char | character | 定義用於對齊文字的字元(與 align = "char" 一起使用),HTML5 中不支援。 |
| Charoff | pixel | 指定相對於使用 char 屬性指定的第一個字元的對齊偏移量(以畫素或百分比值表示),HTML5 中不支援。 |
| Span | number | 定義 <col> 應跨越的列數,HTML5 中不支援。 |
| Valign | bottom middle top baseline | 定義垂直對齊方式,HTML5 中不支援。 |
| Width | 畫素或 % | 指定當前 col 元素跨越的每一列的預設寬度,HTML5 中不支援。 |
示例
您可以嘗試執行以下程式碼來實現 <col> 標籤:
<!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