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" "https://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.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework