colgroup Tag in HTML


The <colgroup> tag in HTML is used to group together a set of columns in a table and apply common properties to them. This tag is typically used in conjunction with the <table> tag to define the layout and appearance of a table.

The <colgroup> tag is placed directly after the opening <table> tag and before the <thead>, <tbody>, or <tfoot> tags. Within the <colgroup> tag, you can define one or more <col> tags, each of which represents a single column in the table. The <col> tag has various attributes that can be used to specify properties such as the width, background color, and text alignment of the column.

Here is an example of how the <colgroup> tag might be used in HTML:

Also Read:  Form Tag in HTML

<col style=”background-color: #ccc;”>
<col style=”text-align: center;”>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
<td>Row 1, Column 3</td>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
<td>Row 2, Column 3</td>

In this example, the <colgroup> tag is used to group together three columns in the table. The first column has a gray background color, the second column is centered, and the third column has no specific styling. The <thead> and <tbody> tags are used to define the header and body sections of the table, respectively, and the individual cells are defined using the <th> and <td> tags.

Previous articlecol Tag in HTML
Next articledata Tag in HTML
Namaskaar, Friends main Kapil ka Founder hu. Mere kai English blog bhi hai ,par mera motive yahan par easy language mein Technology se related Gyan ko aap tak pahunchane ka hai .taki aap kuch naya shikh sake. meri koshish hai ki bilkul simple tarike se aap ko nyi updates deta rahu taki aap bhi technology ke is yug mein peeche na rahe aur shikte rahe.Mujhse judne ke liye app mujhe Social Media par follow kar sakte hai.


Leave a Reply