<colgroup> tag

HTML <colgroup> tag

In HTML, the <colgroup> tag is used to create a group of one or more columns in a table.

Syntax:
<colgroup span=”optional-span-number” class=”optiional-name”> </colgroup>

Note/Info:

The <colgroup> must be a child(descendant) of a <table> tag.

You must code it after the  <caption> element and before the <thead>, <tbody>, <tr> and <tfoot>  elements.

Example

<table>
  <colgroup>
    <col span="3" style="background-color:skyblue">
    <col style="background-color:lightpink">
  </colgroup>
  <tr>
    <th>BIG DATA </th>
    <th>DIGITAL MARKETING</th>
    <th>MAINFRAME </th>
    <th>PROJECT MANAGEMENT </th>
  </tr>
  <tr>
    <td>Spark</td>
    <td>SEO</td>
    <td>COBOL</td>
    <td>Agile</td>
  </tr>
  <tr>
    <td>Scala</td>
    <td>Social Media</td>
    <td>DB2</td>
    <td>Prince2</td>
  </tr>
  <tr>
    <td>HBase</td>
    <td>Content</td>
    <td>JCL</td>
    <td>PMP</td>
  </tr>
  <tr>
    <td>Kafka</td>
    <td>Analytics</td>
    <td>CICS</td>
    <td>ITIL</td>
  </tr>
</table>

Default CSS value

display: table-column-group;

Difference between HTML4.01, XHTML and HTML5

HTML4 XHTML HTML5
NA NA The <colgroup> tag attributes related to HTML4.01 is not supported in HTML5. The span attribute can be used.

Attributes used with <colgroup> tag

Attribute Description
span To set a positive number of columns, a column group can span. The default value is 1.
align To align the content of column group to left, right, center, justify or char.
(HTML5 does not support this attribute when it is used with the <colgroup> tag).
char To align the content of column group in character.
(HTML5 does not support this attribute when it is used with the <colgroup> tag).
charoff To align the number of characters from which the content will align from the character set by the char attribute. This uses a number for this purpose.
(HTML5 does not support this attribute when it is used with the <colgroup> tag).
valign To align the content of column group vertically in a column group to top, bottom, middle or baseline.
(HTML5 does not support this attribute when it is used with the <colgroup> tag).
width Sets the width of the column group in %, pixels or relative_length. units.
(HTML5 does not support this attribute when it is used with the <colgroup> tag).

Global Attributes

The <colgroup> tag supports Global attributes.

Event Attributes

The <colgroup> tag supports Event attributes.

Supporting Browsers

supporting-browsers for tags

Related Tags

<table>, <caption><thead>, <tbody>, <tr> , <col> and <tfoot>  tags.

Tutorials for all brains!