🚀 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 <col> Tag

Stop styling every cell. Learn to control table columns efficiently with colgroups.

table.html
<table>
<colgroup>
<col span="2" />
<col style="..." />
</colgroup>
<!-- Rows... -->
</table>
table-columns.html
1 / 12
🏛️

Tutor:Styling tables can be repetitive. Imagine having to add a class to every single cell (td) just to make a column yellow. That creates messy, redundant code. There is a better way.


Table Mastery

Unlock nodes by mastering column structures.

Concept 1: Table Structure

Before styling columns, we must know the order: `colgroup` always comes first inside the table.

System Check

Can <colgroup> be placed after <tbody>?


Community Holo-Net

Showcase Your Grids

Built a complex pricing table? Share your colgroup configurations.

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!

The Col and Colgroup Tags

Author

Pascual Vila

Frontend Instructor.

When working with tables in HTML, styling individual cells (`td` or `th`) can become repetitive and difficult to maintain. The `col` and `colgroup` tags provide a way to define column properties efficiently.

The Colgroup Container

The <colgroup> element is a container for one or more <col> elements. It must be placed immediately after the opening <table> tag and before any other table elements like `thead`, `tbody`, or `tr`.

The Col Tag

The <col> element is used to specify column properties for each column within a `colgroup`. It is a void element, meaning it does not have a closing tag.

The Span Attribute

The `span` attribute specifies the number of columns a <col> element should span. For example, <col span="2"> will apply its styles to the next two columns in the table structure.

Table Columns Glossary

<colgroup>
Defines a group of columns within a table. Must be a direct child of the table element.
<col>
Defines column properties for each column within a colgroup. It is a self-closing void element.
span
An attribute for the col tag that specifies how many columns the element should affect. Default is 1.