The <colgroup> tag in HTML is used to group one or more <col> elements, allowing styles or attributes to be applied to entire table columns.
- Used to group multiple <col> elements in a table.
- Helps apply styles or attributes (like width) to entire columns.
- Placed inside the <table> tag before <thead>, <tbody>, and <tfoot>.
- Improves table structure and formatting efficiency.
Syntax:
<colgroup>
<col span="2" style="background-color: #f2f2f2;">
<col style="background-color: #e6f7ff;">
</colgroup>
Attributes
- span: span is used to specify the number of columns that have a colgroup tag. The values are in numeric form.