🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEhtml

html Documentation

LOADING ENGINE...

The Colgroup Tag

Stop styling table cells one by one. Learn to control entire columns with a single line of code.

colgroup.html
<!-- Table Config -->
<colgroup>
<col span="2" />
</colgroup>
<!-- Headers -->
<tr>
...
</tr>
📊
colgroup.html
1 / 10
📊

Tutor:Tables in HTML are row-oriented. You create rows <tr> and fill them with cells <td>. But what if you want to style an entire vertical column? Doing it cell by cell is tedious.


Column Mastery

Unlock nodes by learning table structures.

Concept 1: The Container

The <colgroup> element must be the first child of a <table>, before any rows.

System Check

Which element is the parent of <col>?


Community Holo-Net

Share Your Tables

Built a complex schedule or pricing table? Share your column styling tricks.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

HTML Colgroup and Column Styling

Author

Pascual Vila

Frontend Instructor.

When working with tables, you often need to apply styles to an entire vertical column. Standard CSS makes this difficult because tables are row-based.

The Colgroup Element

The <colgroup> element is a container for defining column properties. It sits at the very top of your table structure, immediately after the opening <table> tag and before any rows or headers.

The Col Element

Inside the group, we use the empty <col> tag. This element doesn't hold content; instead, it represents the abstract column itself. You can target it with styles like `background-color` or `border`.

Spanning Multiple Columns

The most powerful feature is the span attribute. If you want three consecutive columns to share the same width or color, you don't need three tags. Just use <col span="3">.

Table Glossary

colgroup
A container tag used to group one or more columns in a table for formatting.
col
A void element that represents a column within a colgroup. It accepts attributes like `span` and `style`.
span
An attribute that specifies the number of consecutive columns a `col` element should extend across.