HTML <colgroup> tagS2C Home   « HTML <colgroup> tag

Definition

The <colgroup> tag is used for defining a group of columns in a table and is used as a container for one or more <col> elements.

The <colgroup> element must follow any <caption> element and precede any <thead>, <tbody>, <tfoot> or <tr> elements.

Example


<table>
  <colgroup>
    <col span="2" style="background-color:purple">
    <col style="background-color:yellow">
  </colgroup>
  <tr>
    <th>Fruit</th>
    <th>Colour</th>
    <th>Quantity</th>
  </tr>
  <tr>
    <td>Banana</td>
    <td>Yellow</td>
    <td>5</td>
  </tr>
  <tr>
    <td>Pea</td>
    <td>Green</td>
    <td>50</td>
  </tr>
</table>
Fruit Colour Quantity
Banana Yellow 5
Pea Green 50

Required Attributes

NONE

Optional Attributes

span specifies the number of columns in a group.


<colgroup span="4">Column group contents here</var>

Global Attributes

Common

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<colgroup class="classname">Column group contents here</var>

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<colgroup id="idname">Column group contents here</var>

style - specifies an inline style for the element allowing you to apply the style to the content.


<colgroup style="color:red;text-align:left">Column group contents here</var>

title - specifies extra information about the content.


<colgroup title="information about the content">Column group contents here</var>

Keyboard

accesskey - specifies a keyboard shortcut to associate with the element.


<colgroup accesskey="aKeyValue">Column group contents here</colgroup>

tabindex - specifies a tab order for the element.


<colgroup tabindex="someNumber">Column group contents here</colgroup>

Language

dir - specifies the directional flow of the content.


<colgroup dir="ltr">Column group contents here</colgroup>;   <!-- The text will flow from left to right -->
<colgroup dir="rtl">Column group contents here</colgroup>;   <!-- The text will flow from right to left -->

lang - specifies a language code for the content of the element.


<colgroup lang="en">Column group contents here</colgroup>;

xml:lang - specifies a language code for the content of the element in XHTML documents.


<colgroup xml:lang="fr">Column group contents here</colgroup>

spellcheck - specifies whether the element is to have its spelling checked.


<!-- Valid values are true and  false - default is inherited / browser specific. -->
<colgroup spellcheck="true">Column group contents here</colgroup>

translate - specifies whether the content of the element can be translated.


<!-- Valid values are yes and  no - default is yes. -->
<colgroup translate="no">Column group contents here</colgroup>

Miscellaneous

contenteditable - specifies whether the content of the element is editable.


<!-- Valid values are true and  false - default is inherited. -->
<colgroup contenteditable="false">Column group contents here</colgroup> 

draggable - specifies whether the the element is draggable.

Only text selections, images, and links can be dragged.


<!-- Valid values are true and  false - default is browser specific. -->
<colgroup draggable="true">Column group contents here</colgroup>

hidden - specifies whether the element is not yet, or no longer, relevant.


<!-- Valid values are an empty string or hidden -->
<colgroup hidden>Column group contents here</colgroup>
<colgroup hidden="hidden">Column group contents here</colgroup>

Event Attributes

Document

onabort - The JavaScript code to be run on abort.


<colgroup onabort="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onerror - The JavaScript code to be run when an error occurs when the file is being loaded.


<colgroup onerror="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onload - The JavaScript code to be run when the document is loaded.


<colgroup onload="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onresize - The JavaScript code to be run when the browser window is resized.


<colgroup onresize="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onscroll - The JavaScript code to be run when the scrollbar of an element is being scrolled.


<colgroup onscroll="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onunload - The JavaScript code to be run once a page has unloaded or the browser window has been closed.


<colgroup onunload="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

Document Element

oncopy - The JavaScript code to be run when the user copies the content of an element.


<colgroup oncopy="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

oncut - The JavaScript code to be run when the user cuts the content of an element.


<colgroup oncut="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onpaste - The JavaScript code to be run when the user pastes some content into an element.


<colgroup onpaste="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

Drag and Drop

ondrag - The JavaScript code to be run when an element is dragged.


<colgroup ondrag="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

ondragend - The JavaScript code to be run when an element has stopped being dragged.


<colgroup ondragend="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

ondragenter - The JavaScript code to be run when an element has been dragged to a valid drop target.


<colgroup ondragenter="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

ondragleave - The JavaScript code to be run when an element leaves a valid drop target.


<colgroup ondragleave="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

ondragover - The JavaScript code to be run when an element is being dragged over a valid drop target.


<colgroup ondragover="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

ondragstart - The JavaScript code to be run at the start of a drag operation.


<colgroup ondragstart="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

ondrop - The JavaScript code to be run when dragged element is being dropped.


<colgroup ondrop="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

Form

onblur - The JavaScript code to be run on abort.


<colgroup onblur="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onchange - The JavaScript code to be run when object changed and attempt to leave field.


<colgroup onchange="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

oncontextmenu - The JavaScript code to be run when a context menu is triggered.


<colgroup oncontextmenu="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onfocus - The JavaScript code to be run when the element gets focus.


<colgroup onfocus="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

oninput - The JavaScript code to be run when an element gets user input.


<colgroup oninput="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

oninvalid - The JavaScript code to be run when an element is invalid.


<colgroup oninvalid="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onreset - The JavaScript code to be run when the reset button of a form is clicked.


<colgroup onreset="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onselect - The JavaScript code to be run when some or all of the contents of an object are selected.


<colgroup onselect="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onsubmit - The JavaScript code to be run when a form is submitted.


<colgroup onsubmit="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

Keyboard

onkeydown - The JavaScript code to be run when an element is in focus and keyboard key is pressed.


<colgroup onkeydown="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onkeypress - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<colgroup onkeypress="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onkeyup - The JavaScript code to be run when an element is in focus and keyboard key is released.


<colgroup onkeyup="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

Media

oncanplay - The JavaScript code to be run when a file has buffered enough so it is ready to start playing.


<colgroup oncanplay="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

oncanplaythrough - The JavaScript code to be run when a file can be played all the way to the end without further need of buffering.


<colgroup oncanplaythrough="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

oncuechange - The JavaScript code to be run when the cue changes when using the track element.


<colgroup oncuechange="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

ondurationchange - The JavaScript code to be run when the length of the media is changed.


<colgroup ondurationchange="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onemptied - The JavaScript code to be run when a media resource element suddenly becomes empty, usually due to an error.


<colgroup onemptied="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onended - The JavaScript code to be run when the media has reach the end.


<colgroup onended="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onloadeddata - The JavaScript code to be run when media data is loaded and playback can start.


<colgroup onloadeddata="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onloadedmetadata - The JavaScript code to be run when metadata has been loaded.


<colgroup onloadedmetadata="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onloadstart - The JavaScript code to be run when the media resource has started loading.


<colgroup onloadstart="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onpause - The JavaScript code to be run when the media resource has been paused.


<colgroup onpause="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onplay - The JavaScript code to be run when the media resource starts playback.


<colgroup onplay="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onplaying - The JavaScript code to be run when playback has already begun.


<colgroup onplaying="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onprogress - The JavaScript code to be run when the browser is fetching the media data.


<colgroup onprogress="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onratechange - The JavaScript code to be run when the playback rate changes.


<colgroup onratechange="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onseeked - The JavaScript code to be run when the seeking attribute is set to false indicating that seeking has finished.


<colgroup onseeked="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onseeking - The JavaScript code to be run hen the seeking attribute is set to true indicating that seeking is currently active.


<colgroup onseeking="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onstalled - The JavaScript code to be run when the browser is unable to continue fetching media data.


<colgroup onstalled="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onsuspend - The JavaScript code to be run when media data has stopped before being completely loaded.


<colgroup onsuspend="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

ontimeupdate - The JavaScript code to be run when the media resources current playback position has changed.


<colgroup ontimeupdate="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onvolumechange - The JavaScript code to be run when the volume has changed or been muted.


<colgroup onvolumechange="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onwaiting - The JavaScript code to be run when the media resource has paused but is expected to resume.


<colgroup onwaiting="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

Mouse

onclick - The JavaScript code to be run when a mouse is clicked on the element.


<colgroup onclick="go()">Column group contents here</colgroup>   <!-- Executes the go() function --> 

ondblclick - The JavaScript code to be run when a mouse is double clicked on the element.


<colgroup ondblclick="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onmousedown - The JavaScript code to be run when the mouse button is pressed down while the cursor is over the element.


<colgroup onmousedown="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onmousemove - The JavaScript code to be run when the mouse button is moved.


<colgroup onmousemove="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onmouseout - The JavaScript code to be run when the mouse cursor moves off an element.


<colgroup onmouseout="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onmouseover - The JavaScript code to be run when the mouse cursor moves over an element.


<colgroup onmouseover="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onmouseup - The JavaScript code to be run when the mouse button is released while the cursor is over the element.


<colgroup onmouseup="go()">Column group contents here</colgroup>   <!-- Executes the go() function -->

onwheel - The JavaScript code to be run when the mouse wheel rolls up or down over an element.


<colgroup onwheel="go()">   <!-- Executes the go() function -->

Window

NONE

go to home page Homepage go to top of page Top