HTML5 <colgroup> Tag

The HTML <colgroup> tag is used to define a group of columns within a table.

The content permitted inside this element depends on whether or not it has a span attribute specified. If the span attribute is present, no other content is permitted inside the element. If the span attribute is not present, zero or more <col> elements are permitted inside the <colgroup> element.

You can omit the start tag of this element, if it has a <col> element as its first child and if it is not preceded by a <colgroup> whose end tag has been omitted. The end tag may be omitted, if it is not followed by a space or a comment.

The parent of the <colgroup> tag can be a <table> element. The <colgroup> must appear after any optional <caption> element but before any <thead>, <th>, <tbody>, <tfoot> and <tr> element.

The following style is applied to this element by default:

colgroup {
  display: table-column-group;
}

Attributes

span

This attribute contains a positive integer indicating the number of consecutive columns the <colgroup> element spans. If not present, its default value is 1.

Further Reading

  1. Read more about the HTML <colgroup> element on MDN.
  2. You can also read the HTML <colgroup> tag reference on W3C.

Reader Comments

1. You can register or login to post a comment. Asking readers to register improves the quality of discussion.

2. As a registered user, you will also get to access features like choosing between a light and dark theme or anything else that we might implement in future.

Follow Us For Updates

FacebookTwitterGoogle+
Go To Top