Tables
HTML <colgroup> element
Groups columns of a table. Use col children or a span attribute, not both in the same group. Place column groups after the caption and before row groups. They describe the column structure, not the row structure; cell associations still need meaningful header markup. It accepts global HTML attributes; individual global features may be inapplicable or restricted.
Formal Syntax & Structure
html syntaxhtml
<colgroup> <col></colgroup>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| span | positive integer | Specifies how many columns a col or applicable colgroup represents. The default is 1; colgroup with span must not also contain col children. |
Return Value
HTMLTableColElement
Content model: No children when span is present; otherwise col and template elements.
Working Example
Example Snippethtml
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>HTML example</title> </head> <body> <table> <colgroup span="2"></colgroup> <tr> <th scope="col">Item</th> <th scope="col">Count</th> </tr> <tr> <td>Books</td> <td>2</td> </tr> </table> </body></html>