Share on Google+Share on Google+

HTML5 colgroup tag, Introduction to <colgroup> tag in html5.

Advertisement
In this illustration we will inform you about the use and implementation of <colgroup> tag in html5

HTML5 colgroup tag, Introduction to <colgroup> tag in html5.

In this illustration we will inform you about the use and implementation of  <colgroup> tag in html5. The <colgroup> tag is used to gather  more than two columns in the table. This tag is used to do easy formatting of columns rather than changing the style of  each cell one by one. This tag is used after <caption> tag and within <table> tag only. The <colgroup> tag can contain legal no. of column  <col> tag only. This tag is used when we want same style for the columns.

Declaration Syntax: 

<colgroup span="value"></colgroup>

This tag have an optional attribute "span". Other attributes like width, align, char, valign are not supported by html5.

The value of "span" attribute is an integer no i.e. no of columns to be grouped which must be a valid no.

Example: Colgroup.html.

<!DOCTYPE html>
<html>
<head>
<title>Example of Colgroup Tag</title>
</head>
<body>
<table border="1">
<caption>
<b>Colgroup Tag</b></caption>
<colgroup span="2" style="background:cyan"></colgroup>
<tr>
     <th>Employee</th>
   <th>DOB</th>
   <th>Address</th>
</tr>
<tr>
   <td>Gyan singh</td>
   <td>1-3-87</td>
   <td>New Delhi</td>
</tr>
</table>
</body> 
</html>

Output:

Download This Example:

Advertisements

Posted on: September 7, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.