如何在 HTML 中包含表格列组?
使用 <colgroup> 标签来包含表格列组。HTML <colgroup> 标签用于指定表格中列组的属性。如果您需要为列组中的列应用不同的属性,可以在 colgroup 标签内使用 HTML col 标签。
以下是属性:
| 属性 | 值 | 描述 |
|---|---|---|
| Align | right left center justify char | 定义水平对齐方式,HTML5 中不支持。 |
| Char | character | 定义用于文本对齐的字符(与 align ="char" 一起使用),HTML5 中不支持。 |
| Charoff | pixel | 定义 <col> 应跨越的列数,HTML5 中不支持 |
| Span | number | 定义 <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