Column group

colgroup

The colgroup element is used with a table element in order to define column styling and column widths. A colgroup comprises one or more "col" elements.

The total number of "col" elements should not be more than the number of columns in the table. (Note: within HTML tables, columns are not defined directly, but indirectly: the row in the table with the greatest number of "td" elements implicitly defines the number of columns for the table.)

More than one colgroup may be specified for a table, each being styled separately using CSS.

Properties

span
The number of columns that this colgroup spans.

Examples

table {
colgroup {
col.gray
col.blue
}
tr {
td AR
td Argentina
}
tr {
td BE
td Belgium
}
tr {
td CA
td Canada
}
}
style {
.gray { background-color: #777; }
.blue { background-color: #77F; }
}
One colgroup, two cols with CSS classnames

table {
colgroup.gray {
col
}
colgroup.blue {
col
col
col
}
tr {
th Country
th ISO-3166 alpha-2
th ISO-3166 alpha-3
th UN code
}
tr {
th Argentina
td AR
td ARG
td 032
}
tr {
th Belgium
td BE
td BEL
td 056
}
tr {
th Canada
td CA
td CAN
td 124
}
}
style {
.gray { background-color: #777; }
.blue { background-color: #77F; }
}
Two colgroups: one for row headers, one for cell data
0

semantax > row-column > colgroupColumn group

🔗 🔎