You are here: Reference > HTML > tags > colGroup

colGroup element

Browser support:
Specifies property defaults for a group of columns in a table.
The colgroup tag is used to specify column dependent attributes for a table. You can use the col element to override the attributes of the colgroup for a specific column.
This element must be placed within a table element.
Note that Firefox, Google Chrome, Safari and Opera have only partial support for this element.
For more information, please see the page for the table element.
If you want to see the HTML tags by categories, please visit this page.
This element requires a closing tag.
JavaScript page for this element: colGroup.

Possible members:

Attributes
Events
Styles
align
Sets the horizontal alignment of the contents in an object.
bgColor
Sets the background color of one or more specified columns in a table element.
ch
Sets an alignment character. The alignment of the contents of the cells in the same column depends on this character. The first occurrence of the alignment character in each cell in a column will be on a vertical axis.
char
Sets an alignment character. The alignment of the contents of the cells in the same column depends on this character. The first occurrence of the alignment character in each cell in a column will be on a vertical axis.
charOff
Sets the horizontal offset of the ch and char attributes. The direction of the offset is the same as the direction of the text (dir attribute).
chOff
Sets the horizontal offset of the ch and char attributes. The direction of the offset is the same as the direction of the text (dir attribute).
class
Sets the style class or classes that belong to the element.
dir
Sets the text direction as related to the lang attribute.
DISABLED
Sets the state of an object for user interaction.
HIDEFOCUS
Specifies whether a dotted rectangle (focus rectangle) is drawn around an object while it has focus.
id
Sets a unique identifier for the object.
lang
Specifies the language of the element.
name
Sets the name of an element.
span
Specifies the number of columns in a column group that share the settings defined in the col element.
style
Sets an inline style associated with an element.
vAlign
Specifies the vertical alignment of the text within an object.
width
Specifies the default width of the element.
xml:lang
Sets the language code of the XML document.

Example HTML code 1:

This example illustrates the use of the colGroup element:
<table border="1px">
    <colgroup style="background-color: #a0a0f0;">
        <col style="background-color: #a0f0a0;" />
        <col span="2" />
    </colgroup>
    <tbody>
        <tr>
            <td>Apple</td>
            <td>$5</td>
            <td>$10.7</td>
        </tr>
        <tr>
            <td>Pear</td>
            <td>$10.50</td>
            <td>$8.20</td>
        </tr>
        <tr>
            <td>Peach</td>
            <td>$23.30</td>
            <td>$19.45</td>
        </tr>
    </tbody>
</table>
Did you find this example helpful? yes no

Related pages:

External links:

User Contributed Comments

Post Content

Post Content