HTML TUTORIALS-
HTML Table Colgroup Tag –
Introduction-
HTML Table Colgroup Tag -
-✅ What is <colgroup>Syntax?- This is used to group one or more columns in a table for styling or structural purposes. It's especially useful when you want to apply styles (like width or background color etc) to entire columns:-
-)✅ Example 1: Set Column Widths-👇
<table border="1">
<colgroup>
<col style="width: 100px;">
<col style="width: 200px;">
</colgroup>
<tr>
<th>Name</th>
<th>City</th>
</tr>
<tr>
<td>Alice</td>
<td>New York</td>
</tr>
</table>
| Name | City |
|---|---|
| Pramod | Pune |
<table border="1">
<colgroup>
<col style="background-color: lightblue;">
<col style="background-color: lightyellow;">
</colgroup>
<tr>
<th>Product</th>
<th>Price</th>
</tr>
<tr>
<td>Ball</td>
<td>$3.50</td>
</tr>
</table>
| Product | Price |
|---|---|
| Ball | $3.50 |
<table border="1">
<colgroup>
<col span="2" style="background-color: #eee;">
<col style="background-color: #cfc;">
</colgroup>
<tr>
<th>First</th>
<th>Last</th>
<th>Country</th>
</tr>
<tr>
<td>Pramod</td>
<td>Behera</td>
<td>IND</td>
</tr>
</table>
| First | Last | Country |
|---|---|---|
| Pramod | Behera | IND |
<table border="1">
<colgroup>
<col>
<col style="background-color: #fdd;">
<col>
</colgroup>
<tr>
<th>Item</th>
<th>Qty</th>
<th>Price</th>
</tr>
<tr>
<td>Laptop</td>
<td>5</td>
<td>$300</td>
</tr>
</table>
| Item | Qty | Price |
|---|---|---|
| Laptop | 5 | $300 |
| Tag | Purpose |
|---|---|
| <table> | Defines the table |
| <tr> | Table row |
| <th> | Table header (bold + centered by default) |
| <td> | Table data (cell content) |
| <caption> | Defines a table caption |
| <colgroup> | Specifies a group of one or more columns in a table for formatting |
| <col> | Specifies column properties for each column within a (colgroup) element |
| <thead> | Groups the header content in a table |
| <tbody> | Groups the body content in a table |
-Specify a valid MRP Procedure
-Movement type 161 is not allowed