"if you encounter any errors in SAP, send me a screenshot at pramod@learntosap.com, and I will help you resolve the issue."

HTML Table Colgroup Tag –

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:-

Trulli Trulli

-)✅ 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

✅ Example 2: Style Column Backgrounds-👇


<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

✅ Example 3: Span Multiple Columns-👇


<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

✅ Example 4: — With Empty Tags for Control-👇


<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 Breakdown-

Table Tag Breakdown

-) Table Tag Breakdown -

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

Live Code Preview


May Be Like Important Link-

-Specify a valid MRP Procedure

-Movement type 161 is not allowed

-Specify a valid MRP Procedure

-Cash Journal Entry (PETTY CASH)