colgroup ... ⁄colgroup
HTML5 colgroup element
The colgroup element allows you to group one or more columns in a table. »video
The number of columns to be grouped in that colgroup can be specified through span attribute or by using the element:
span="1" → 1 column
→ 1 column
Warning: use either either span at a time (if both used, span is ignored).
About colgroup
- is an optional element »examples
- multiple colgroup elements allowed per HTML5 document, in the same table or in multiple table elements
Display & support colgroup
- display in browser »video





Parents, children colgroup
- colgroup nested within elements »colgroup parents
- elements nested within colgroup »colgroup children
»examples
»video
The colgroup element is the second optional element inside table element (table's second child).
Attributes colgroup
- required: none
- optional: specific attributes, global attributes, event attributes
Syntax colgroup
1 2 3 4 | <> ... <⁄> <> ... ... <⁄> ... » video |
Attributes and Values colgroup (comma separated)
< | attribute | = | "attribute_value(s)" | > | Video | Examples |
---|---|---|---|---|---|---|
1. specific attributes | ||||||
1. | span | = | integer | »video | <span="2"> ... <⁄ > | |
All Specific Attributes | ||||||
2. global attributes | ||||||
1. | accesskey | = | keyboard key | »img | <accesskey="h"> ... </ > | |
2. | class | = | class name | »html »img | <class="class_name"> ... </ > | |
3. | contenteditable | = | "", , true, false | »html | <contenteditable="true"> ... </ > | |
4. | contextmenu | = | menu id value | »html | <contextmenu="menu_id_value"> ... </ > | |
5. | data-* | = | value | - | <data-http-error="404"> ... </ > | |
6. | dir | = | ltr, rtl, auto | »html | <dir="ltr"> ... </ > | |
7. | draggable | = | true, , false | »img | <draggable="false"> ... </ > | |
8. | dropzone | = | copy, move, link, string:, file: | - | <dropzone="copy"> ... </ > | |
9. | hidden | = | "", , hidden | »html »img | <hidden="hidden"> ... </ > | |
10. | id | = | id name | »html »img | <id="unique_id_name"> ... </ > | |
11. | itemid | = | URL | - | - | |
12. | itemprop | = | string | »link »a | - | |
13. | itemref | = | string | - | - | |
14. | itemscope | = | "", , itemscope | - | - | |
15. | itemtype | = | absolute URL | - | - | |
16. | lang | = | language code | »html »head»title »img | <lang="en"> ... </ > | |
17. | spellcheck | = | "", , true, false | »html | <spellcheck="true"> ... </ > | |
18. | style | = | CSS property:value | »html »img | <style="color:red"> ... </ > | |
19. | tabindex | = | integer | »img | <tabindex="3"> ... </ > | |
20. | title | = | text | »html »link»style »abbr»dfn »img »meter | <title="html page"> ... </ > | |
21. | translate | = | "", yes, no | »html »img | <translate="yes"> ... </ > | |
All Global Attributes | ||||||
3. global event attributes | ||||||
1. | onclick | = | script | » list | <element onclick="script" > ... | |
2. | ondblclick | = | script | » list | <element ondblclick="script" > ... | |
All Event Attributes |
Video demonstration colgroup element
HTML5 colgroup element: group columns in a table
min | video details |
---|---|
00:04 | video tutorial: colgroup tag, grouping columns in a tabel |
00:04 | colgroup element allows you to group one or more columns in a group inside a table |
00:13 | adding colgroup element in page, inside table element |
00:20 | the number of columns to be grouped inside the colgroup element can be specified through col element |
00:24 | our table has 4 columns which can be grouped inside colgroup (colgroup = a column group) |
00:30 | let's group the first 2 columns in a first group |
00:34 | group = literally adding the col tag inside colgroup; 1 col = 1 colun; 2 col = 2 columns ... |
00:39 | and the next 2 columns in another group (a 2nd colgroup) |
00:49 | the 4 columns were grouped as follows |
00:57 | let's make visible the 2 groups of columns through CSS by adding a 6px border to each; by default the colgroup elements are not visible in browser |
01:02 | thus we have: 2 columns <col><col> grouped in the first colgroup & 2 columns <col><col> grouped in the second colgroup |
01:08 | we can group 3 columns in the first colgroup and 1 in the second |
01:19 | you can specify a unique style for each column <col>, BUT in case the same style applies to multiple columns, a group of columns, you can span those columns like this: |