content logo

Learn HTML:

HTML colgroup tag

The HTML <colgroup> tag is used for specifying properties for a group of columns within a table.

 

If you need to apply different properties to a column within a colgroup, you can use the HTML col tag within the colgroup tag..

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML colgroup Tag</title>
</head>
<body>
<p>This example shows a colgroup that has three columns of different widths:</p>
<table border="1">
<colgroup span="3">
<col width="50"></col>
<col width="100"></col>
<col width="200"></col>
</colgroup>
<tr>
<td>col 1</td>
<td>col 2</td>
<td>col 3</td>
</tr>
</table>
</body>
</html>

This will produce following result:

 

This example shows a colgroup that has three columns of different widths:

col 1 col 2 col 3

 

Specific Attributes

 

The HTML <colgroup> tag also supports following additional attributes:

 

Attribute Value Description
align right
left
center
justify
char
Defines horizontal alignment, not supported in Html5.
char character Defines a character to use to align text on (use with align="char"), not supported in Html5.
charoff pixel Specifies an alignment offset (either in pixels or percentage value) against the first character as specified with the char attribute, not supported in Html5.
span number Defines the number of columns the <col> should span, not supported in Html5.
valign bottom
middle
top
baseline
Defines vertical alignment, not supported in Html5.
width pixels or % Specifies a default width for each column spanned by the current col element, not supported in Html5 .
#

HTML Colgroup Tag Definition

#

HTML Colgroup Tag Usage

#

HTML Colgroup Tag Examples