HTML colgroup tag and element
HTML colgroup element
1. HTML colgroup (column group) element represents a structural division of an HTML table.
2. A colgroup starts with <colgroup> tag. And ends with </colgroup> tag, which is optional.
3. Using colgroup is useful when you want to apply certain style or attributes to a number of table columns.
Syntax
<colgroup>
.......
</colgroup>
Category
HTML colgroup element is a part of HTML Tables.
Whether both start and end tags are required
Start tag is required but end tag is optional.
Can contain
HTML colgroup element can contain one or more tr elements.
Can reside within
HTML colgroup element can reside within table element.
Attributes
Identifiers
language information and text direction
Title
Style
Events
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup.
Cell alignment
align, char and charoff attributes.
Supported doctypes
HTML 4.01 Strict, HTML 4.01 Transitional, and HTML 4.01 Frameset.
Example of using HTML colgroup element
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML colgroup element</title>
</head>
<body>
<table width="100%" border="1"><colgroup span="2"></colgroup>
<tr>
<th>Name</th>
<th>Designation</th>
<th>Salary</th>
</tr>
<tr>
<td>Subroto Dey. </td>
<td>Regional head, Sales </td>
<td>$1500</td>
</tr>
</table>
</body>
</html>
Result
View this example in a separate browser window
Pictorial presentation
Previous: HTML tbody tag and element
Next:
HTML col tag and element
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/html/colgroup/HTML-colgroup-tag-and-element.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics