HTML Tag Reference - HTML tag <colgroup>








This <colgroup> element groups table columns together and allows the grouped columns to share properties and style settings.

Browser compatibility

<colgroup> Yes Yes Yes Yes Yes

What's new in HTML5

Some of the attributes in HTML 4.01 are not supported in HTML5.

Attribute

align
Value:left|right|center|justify|char
Not supported in HTML5. Set the alignment
char
Value:character
Not supported in HTML5. Set to align the content to a character
charoff
Value:number
Not supported in HTML5. Set the number of characters from the character specified by the char attribute to align the content
span
Value:number
Set the number of columns a column group should span
valign
Value:top|middle|bottom|baseline. Not supported in HTML5. Set to vertical align the content in a column group
width
Value:pixels|%|relative length Not supported in HTML5. Set the width of a column group

Global Attributes

The <colgroup> tag supports the Global Attributes in HTML.





Event Attributes

The <colgroup> tag supports the Event Attributes in HTML.

Default CSS Settings

colgroup { 
    display: table-column-group;
}

Example

A demo showing how to use <colgroup>.

<html>
<body>
     <table>
          <colgroup span="2" style="color: blue;"></colgroup>
          <colgroup style="color: red;"></colgroup>
          <tr>
               <td>col: 1, group: 1</td>
               <td>col: 2, group: 1</td>
               <td>col: 3, group: 2</td>
          </tr>
          <tr>
               <td>col: 1, group: 1</td>
               <td>col: 2, group: 1</td>
               <td>col: 3, group: 2</td>
          </tr>
          <tr>
               <td>col: 1, group: 1</td>
               <td>col: 2, group: 1</td>
               <td>col: 3, group: 2</td>
          </tr>
     </table>
</body><!--from   w  w  w .  j  a  v  a 2s . c  o m-->
</html>

Click to view the demo