The HTML <colgroup>
aspect defines a gaggle of columns inside a desk. It’s used to specify properties for a column or a gaggle of columns in a desk utilizing the <col>
aspect.
Syntax
1 |
<colgroup>
|
2 |
<col>
|
3 |
<col>
|
4 |
... |
5 |
</colgroup>
|
Instance
On this instance we use the <colgroup>
tags to fashion the columns. Be aware using the span
and fashion
attributes to do that.
Syntax
1 |
<desk>
|
2 |
<caption>Newest attire</caption> |
3 |
<colgroup>
|
4 |
<col fashion="background-color: #222222;"> |
5 |
<col span="2" fashion="background-color: #39483d;"> |
6 |
</colgroup>
|
7 |
<thead>
|
8 |
... |
End result
Attributes
The <colgroup>
aspect helps World Attributes in HTML. World Attributes are frequent to all HTML components and can be utilized on all of them (although they might not have a lot of an impact on a few of them).
The <colgroup>
aspect particularly makes use of the next attributes:
Attribute | Values | Description |
align |
left heart proper justify char
|
Units the horizontal alignment of content material inside every column within the group.
|
char |
char
|
Specifies the alignment character for cells in a column.
|
charoff |
size | Specifies the offset of the alignment character for cells in a column. |
span |
quantity | Specifies the variety of columns a <col> aspect ought to span. |
valign |
high center backside baseline | Units the vertical alignment of content material inside every column within the group. |
width |
size | Specifies the width of a column within the group. |
Content material
The <colgroup>
aspect can include a number of <col>
components, which symbolize particular person columns throughout the group until the span
attribute is current.
Did You Know?
- The
<colgroup>
aspect is commonly used to use frequent styling or formatting to a number of columns in a desk, with out having to specify the identical attributes for every particular person<col>
aspect. - If a desk accommodates each
<colgroup>
and<col>
components that apply to the identical column, the<col>
aspect takes priority.