Deutsch | English | Español | Français |
Italiano | 日本語 | 한국어 | Português |
Pусский | 简体中文 | 繁體中文 |
Specifies property defaults for a column or group of columns in a table.
![]() |
HTML information
Closing Tag | required |
---|---|
CSS Display | block |
DOM Information
Inheritance Hierarchy
Members
The colGroup object has these types of members:
Events
The colGroup object has these events.
Event | Description |
---|---|
abort |
Fires when the user aborts the download. |
afterupdate |
Fires on a databound object after successfully updating the associated data in the data source object. |
beforecopy |
Fires on the source object before the selection is copied to the system clipboard. |
beforeupdate |
Fires on a databound object before updating the associated data in the data source object. |
cellchange |
Fires when data changes in the data provider. |
change |
Fires when the contents of the object or selection have changed. |
dataavailable |
Fires periodically as data arrives from data source objects that asynchronously transmit their data. |
datasetchanged |
Fires when the data set exposed by a data source object changes. |
error |
Fires when an error occurs during object loading. |
errorupdate |
Fires on a databound object when an error occurs while updating the associated data in the data source object. |
filterchange |
Fires when a visual filter changes state or completes a transition. |
input |
Occurs when the text content of an element is changed through the user interface. |
layoutcomplete |
Fires when the print or print preview layout process finishes filling the current LayoutRect object with content from the source document. |
load |
Fires immediately after the client loads the object. |
ondatasetcomplete |
Fires to indicate that all data is available from the data source object. |
onselect |
Fires when the current selection changes. |
readystatechange |
Fires when the state of the object has changed. |
reset |
Fires when the user resets a form. |
resize |
Fires when the size of the object is about to change. |
rowenter |
Fires to indicate that the current row has changed in the data source and new data values are available on the object. |
rowexit |
Fires just before the data source control changes the current row in the object. |
rowsdelete |
Fires when rows are about to be deleted from the recordset. |
rowsinserted |
Fires just after new rows are inserted in the current recordset. |
Methods
The colGroup object has these methods.
Method | Description |
---|---|
addBehavior |
Attaches a behavior to the element. |
appendChild |
Appends an element as a child to the object. |
applyElement |
Makes the element either a child or parent of another element. |
attachEvent |
Note
attachEvent is no longer supported. Starting with IE11, use
addEventListener. For info, see
Compatibility changes.
Binds the specified function to an event, so that the function gets called whenever the event fires on the object. |
clearAttributes |
Removes all attributes and values from the object. |
click |
Simulates a click by causing the onclick event to fire. |
cloneNode |
Copies a reference to the object from the document hierarchy. |
componentFromPoint |
Returns the component located at the specified coordinates via certain events. |
contains |
Checks whether the given element is contained within the object. |
detachEvent |
Unbinds the specified function from the event, so that the function stops receiving notifications when the event fires. |
doScroll |
Note
doScroll is no longer supported. Starting with IE11, use
scrollLeft or
scrollTop. For info, see
Compatibility changes.
Simulates a click on a scroll bar component. |
fireEvent |
Fires a specified event on the object. |
getAdjacentText |
Returns the adjacent text string. |
getAttribute |
Retrieves the value of the specified attribute. |
getAttributeNode |
Retrieves an attribute object referenced by the attribute. name property. |
getAttributeNodeNS |
Gets an attribute object that matches the specified namespace and name. |
getAttributeNS |
Gets the value of the specified attribute within the specified namespace. |
getBoundingClientRect |
Retrieves an object that specifies the bounds of a collection of TextRectangle objects. |
getClientRects |
Retrieves a collection of rectangles that describes the layout of the contents of an object or range within the client. Each rectangle describes a single line. |
getElementsByClassName |
Gets a collection of objects that are based on the value of the class attribute. |
getElementsByTagName |
Retrieves a collection of objects based on the specified element name. |
getElementsByTagNameNS |
Gets a collection of objects that are based on the specified element names within a specified namespace. |
hasAttribute |
Determines whether an attribute with the specified name exists. |
hasAttributeNS |
Determines whether an attribute that has the specified namespace and name exists. |
hasAttributes |
Determines whether one or more attributes exist for the object. |
hasChildNodes |
Returns a value that indicates whether the object has children. |
insertAdjacentElement |
Inserts an element at the specified location. |
insertAdjacentHTML |
Inserts the given HTML text into the element at the location. |
insertAdjacentText |
Inserts the given text into the element at the specified location. |
insertBefore |
Inserts an element into the document hierarchy as a child node of a parent object. |
mergeAttributes |
Copies all read/write attributes to the specified element. |
msMatchesSelector |
Determines whether an object matches the specified selector. |
normalize |
Merges adjacent DOM objects to produce a normalized document object model. |
querySelector |
Retrieves the first DOM element node from descendants of the starting element node that match any selector within the supplied selector string. |
querySelectorAll |
Retrieves all DOM element nodes from descendants of the starting element node that match any selector within the supplied selector strings. |
removeAttribute |
Removes an attribute from an object. |
removeAttributeNode |
Removes an attribute object from the object. |
removeAttributeNS |
Removes the specified attribute from the object. |
removeBehavior |
Detaches a behavior from the element. |
removeChild |
Removes a child node from the object. |
removeNode |
Removes the object from the document hierarchy. |
replaceAdjacentText |
Replaces the text adjacent to the element. |
replaceChild |
Replaces an existing child element with a new child element. |
replaceNode |
Replaces the object with another element. |
scrollIntoView |
Causes the object to scroll into view, aligning it either at the top or bottom of the window. |
setActive |
Sets the object as active without setting focus to the object. |
setAttribute |
Sets the value of the specified attribute. |
setAttributeNode |
Sets an attribute object node as part of the object. |
setAttributeNodeNS |
Sets an attribute object as part of the object. |
setAttributeNS |
Sets the value of the specified attribute within the specified namespace. |
setCapture |
Sets the mouse capture to the object that belongs to the current document. |
swapNode |
Exchanges the location of two objects in the document hierarchy. |
Properties
The colGroup object has these properties.
Property | Description |
---|---|
Sets or retrieves the alignment of the object relative to the display or table. | |
Specifies whether the element and its contents must be selected as a whole, indivisible unit. | |
Retrieves a collection of attributes of the object. | |
Sets the background color behind an object. | |
Gets a value indicating whether the object can contain child objects. | |
Retrieves the value indicating whether the object can contain rich HTML markup. | |
Retrieves the number of immediate child nodes of the current element or a zero if the element does not contain any child nodes. childElementCount does not return all child nodes, only child nodes that are nodeType =1, or element nodes. | |
Sets or retrieves the class of the object. | |
Retrieves the height of the object including padding, but not including margin, border, or scroll bar. | |
Retrieves the distance between the offsetLeft property and the true left side of the client area. | |
Retrieves the distance between the offsetTop property and the true top of the client area. | |
Retrieves the width of the object including padding, but not including margin, border, or scroll bar. | |
Sets or retrieves the reading order of the object. | |
Gets a reference to the first child in the childNodes collection of the object. | |
Retrieves a reference to the first child element, or null if there are no child elements. | |
Sets or retrieves the string identifying the object. | |
Sets or retrieves the HTML between the start and end tags of the object. | |
Sets or retrieves the text between the start and end tags of the object. | |
Gets the value that indicates whether the user can edit the contents of the object. | |
Gets the value that indicates whether the user can interact with the object. | |
Retrieves the value indicating whether the content of the object contains one or more lines. | |
Retrieves whether a TextRange object can be created using the object. | |
Sets or retrieves the language to use. | |
Sets or retrieves the language in which the current script is written. Note This has been superceded by the type attribute for the script element. If you are using javascript alone, you don't need to specify a type or language with the script element.
| |
Gets a reference to the last child in the childNodes collection of an object. | |
Retrieves a reference to the last child element or null if there are no child elements. | |
Retrieves a reference to the sibling element that immediately follows or null if the element does not have any sibling elements that follow it. | |
Retrieves a reference to the next child of the parent for the object. | |
Gets the name of a particular type of node. | |
Retrieves the type of the requested node. | |
Gets or sets the value of a node. | |
Retrieves the height of the object relative to the layout or coordinate parent, as specified by the offsetParent property. | |
Retrieves the calculated left position of the object relative to the layout or coordinate parent, as specified by the offsetParent property. | |
Retrieves a reference to the container object that defines the offsetTop and offsetLeft properties of the object. | |
Retrieves the calculated top position of the object relative to the layout or coordinate parent, as specified by the offsetParent property. | |
Retrieves the width of the object relative to the layout or coordinate parent, as specified by the offsetParent property. | |
Sets or retrieves the object and its content in HTML. | |
Sets or retrieves the text of the object. | |
Retrieves the document object associated with the node. | |
Retrieves the parent object in the object hierarchy. | |
Retrieves the parent object in the document hierarchy. | |
Retrieves the container object in the document hierarchy that can be used to create a TextRange containing the original object. | |
Retrieves a reference to the immediately preceding sibling element or null if the element does not have any preceding siblings. | |
Gets a reference to the previous child of the parent for the object. | |
Retrieves the current state of the object. | |
Retrieves the ordinal record from the data set that generated the object. | |
Sets or retrieves the role for this element. | |
Gets the namespace defined for the element. This property is not supported for Windows apps using JavaScript. | |
Retrieves the scrolling height of the object. | |
Sets or retrieves the distance between the left edge of the object and the leftmost portion of the content currently visible in the window. | |
Sets or retrieves the distance between the top of the object and the topmost portion of the content currently visible in the window. | |
Retrieves the scrolling width of the object. | |
Retrieves the ordinal position of the object, in source order, as the object appears in the document's all collection. | |
Sets or retrieves the number of columns in the group. | |
Sets an inline style for the element. | |
Retrieves the tag name of the object. | |
Sets or gets the URN specified in the namespace declaration. This property is not supported for Windows apps using JavaScript. | |
Sets or retrieves advisory information (a ToolTip) for the object. | |
Retrieves an autogenerated, unique identifier for the object. | |
Retrieves the element's unique number. | |
Sets or retrieves how text and other content are vertically aligned within the object that contains them. | |
Sets or retrieves the width of the object. |
Standards information
- HTML 4.01 Specification, Section 11.2.4
Remarks
Nested COL elements override COLGROUP elements.
Use the SPAN attribute to specify the number of table columns that the COLGROUP defines. This attribute has a default value equal to one.
COL elements can occur outside of a COLGROUP element, and these two elements can be used for similar purposes. However, you must use the COLGROUP element to determine where table internal dividing lines ( rules) should go. This is illustrated in the first example .
You should avoid using the SPAN attribute inside the COLGROUP element if there are COL elements nested within it. This is because the SPAN attribute that belongs to the nested COL elements will override the attribute that belongs to the COLGROUP element. This can cause confusing code and possibly unintended results. This behavior is illustrated in the second example.
The table object and its associated elements have a separate table object model, which uses different methods than the general object model. For more information on the table object model, see Building Tables Dynamically.
Windows Internet Explorer 8 will only render tables up to 1000 columns. To force Windows Internet Explorer 7 rendering mode, see How Do I Take Advantage of the New Features in Internet Explorer 8.
Examples
This example uses the COLGROUP element to assign specific characteristics to two groups of columns in a table.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/colgroupEX1.htm
<html>
<body>
<table border="2" rules="groups">
<!-- RULES is set to "groups", which places internal dividing lines around
table columns defined by colgroup. -->
<colgroup span="2" style="color: red">
</colgroup>
<colgroup style="color: blue">
</colgroup>
<tr>
<td>This column is in the first group.</td>
<td>This column is in the first group.</td>
<td>This column is in the second group.</td>
</tr>
<tr>
<td>This column is in the first group.</td>
<td>This column is in the first group.</td>
<td>This column is in the second group.</td>
</tr>
</table>
</body>
</html>
When COL elements are nested inside a COLGROUP element, the attributes of the COL elements override the attributes of the COLGROUP element. In this example, the last column has no formatting even though COLGROUP spans over all three columns. This happens because the SPAN attribute of the nested COL element overrides the SPAN attribute of the COLGROUP.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/colgroupEX2.htm
<html>
<body>
<table border="2">
<colgroup span="3" style="color: green; background: black">
<!-- Styling is applied to only the first two columns, instead of all
three, and the font color is red instead of green. This is consistent
with the attributes of the COL element. -->
<col span="2" style="color: red">
</colgroup>
<tr>
<td>This column is in the first group.</td>
<td>This column is in the first group.</td>
<td>This column is in the second group.</td>
</tr>
<tr>
<td>This column is in the first group.</td>
<td>This column is in the first group.</td>
<td>This column is in the second group.</td>
</tr>
</table>
</body>
</html>
See also