The <colgroup> tag is used to group columns in a <table> for formatting.
The <colgroup> tag is useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row.
The <colgroup> tag can only be used inside a <table> element.
Column group. Specifies attributes to be applied to a set of table columns. Often used with <col> elements.
- Option
<colgroup> Attributes:
span can be used to specify the number of columns the <colgroup> element applies to.
align can be used to horizontally align the cells within the column group. The value can be left, center, right, justify or char.
valign can be used to vertically align the cells within the column group. The value can be top, middle, bottom or baseline.
char can be used to specify a character with which cells will align, such as a decimal point. It is not supported by any major browser.
charoff can be used to specify the number of pixels the alignment should be offset from the char character. It is not supported by any major browser.
The <colgroup> is a container for a number of <col> elements, and allows you to set attributes that you might otherwise set at col level on a number of <col> elements simultaneously—the attributes defined at this higher level apply to all of the child columns. It is important to note that if you use one or more <colgroup> then all <col>s must be enclosed in one or more <colgroup>s.