HTML <col> Tag

Beginner
7 min read
Updated: Oct 2026
4 examples
Live preview

Definition and Usage

The <col> element defines one or more columns inside a <colgroup>. Use it to apply column-level styles (such as background or width) without repeating rules on every cell.

It is valid only as a child of <colgroup> that has no span attribute. <col> is a void element (start tag only). Prefer CSS over the old presentational attributes.

Baseline · Widely available.

Not deprecated as an element. Stable across browsers since about July 2015 (and earlier in practice). Some CSS effects on columns have limits.

Deprecated attributes.

Do not use align, bgcolor, char, charoff, valign, or width on <col>. Use CSS instead.

HTML Syntax

syntax.html
<colgroup><col span=" n"></colgroup>

No end tag and no content. Put one or more <col> elements inside <colgroup> (without span on that colgroup).

Attributes

Modern and legacy attributes you may see on <col>:

AttributeDescriptionTry it
spanHow many consecutive columns this <col> covers. Positive integer; default 1.Try it
widthDeprecated — use CSS width insteadTry it
alignDeprecated — use CSS text-align insteadTry it
valignDeprecated — use CSS vertical-align insteadTry it
bgcolorDeprecated — use CSS background-color insteadTry it
char / charoffDeprecated — use CSS text-align (and tabular numerals) insteadTry it

Global Attributes

The <col> tag also supports the Global Attributes in HTML.

Live Preview

Change which column gets a background via real <col> elements.

Background on <col> shows when cell backgrounds are transparent.

Table
NameRoleTeam
AlexDesignA
SamDevB

Column 1 highlighted with background on <col>

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Style One Column

Place <col> elements inside <colgroup> and style with CSS.

HTML
<style>
  .accent { background-color: #eff6ff; }
</style>

<table>
  <colgroup>
    <col class="accent">
    <col>
  </colgroup>
  <tr>
    <th scope="col">Name</th>
    <th scope="col">Score</th>
  </tr>
  <tr>
    <td>Ada</td>
    <td>95</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Open <colgroup> without a span attribute.
  2. Add one <col> per column (or use span later to cover several).
  3. Put a class on the column you want to style.
  4. Set background-color in CSS on that class — cells stay transparent so the column color shows.

Example 2 — One col Spans Two Columns

Use span so one <col> styles several consecutive columns.

HTML
<style>
  .pair { background-color: #fef9c3; }
</style>

<table>
  <colgroup>
    <col>
    <col span="2" class="pair">
  </colgroup>
  <tr>
    <th scope="col">Item</th>
    <th scope="col">Q1</th>
    <th scope="col">Q2</th>
  </tr>
  <tr>
    <td>Books</td>
    <td>12</td>
    <td>18</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. First <col> covers column 1 (default span="1").
  2. Second <col span="2"> covers columns 2 and 3 together.
  3. One class styles both spanned columns the same way.
  4. Column count of all col spans should match the number of cells in each row.

Example 3 — Column Width with CSS

Set column width with CSS, not the deprecated width attribute.

HTML
<style>
  .narrow { width: 30%; }
  .wide { width: 70%; }
</style>

<table>
  <colgroup>
    <col class="narrow">
    <col class="wide">
  </colgroup>
  <tr>
    <th scope="col">Code</th>
    <th scope="col">Description</th>
  </tr>
  <tr>
    <td>A1</td>
    <td>Introductory HTML tables</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. Skip width="…" on <col> — that attribute is obsolete.
  2. Assign classes to each column.
  3. Set CSS width on those classes (acts like a minimum width for the column).
  4. Keep cell content transparent for backgrounds if you also color columns.

Example 4 — Weekday and Weekend Columns

Group several days with span and different background classes (MDN-style pattern).

HTML
<style>
  .weekdays { background-color: #dbeafe; }
  .weekend { background-color: #fef9c3; }
</style>

<table>
  <colgroup>
    <col>
    <col span="5" class="weekdays">
    <col span="2" class="weekend">
  </colgroup>
  <tr>
    <th>Period</th>
    <th>Mon</th><th>Tue</th><th>Wed</th>
    <th>Thu</th><th>Fri</th>
    <th>Sat</th><th>Sun</th>
  </tr>
  <tr>
    <th scope="row">a.m.</th>
    <td>Study</td><td>Gym</td><td>Class</td>
    <td>Lab</td><td>Shop</td>
    <td>Rest</td><td>Free</td>
  </tr>
</table>
Try It Yourself

How It Works

  1. First column is the period label (<col> with default span 1).
  2. span="5" styles Monday–Friday together.
  3. span="2" styles Saturday–Sunday together.
  4. 1 + 5 + 2 = 8, matching eight cells in each row.

Edge Cases & Pitfalls

Most col bugs are wrong parents, painted-over backgrounds, or deprecated attributes.

parent

Only inside colgroup without span

Do not put <col> directly under <table>. If colgroup has span, it cannot contain col children.

css

Limited CSS on col

Reliable effects include background, width, visibility: collapse, and borders when border-collapse: collapse. text-align on col does nothing useful.

layers

Cell backgrounds hide column color

Column backgrounds sit under row and cell backgrounds. Opaque th/td fills will cover the column color.

count

Spans must match columns

The total of all col span values should equal the number of columns in the table body.

deprecated

Skip presentational attributes

width, align, valign, bgcolor, char, and charoff are obsolete — migrate to CSS.

Browser Support

The <col> element is core HTML for tables in every modern browser. Column CSS support is solid for background and width; some older presentational attributes vary.

✓ Baseline · Widely available

<col>

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support col inside colgroup. Prefer CSS over deprecated HTML presentational attributes.

98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported
<col> Widely supported

Bottom line: Safe to use for column styling inside colgroup. Stick to CSS for color and width; ignore deprecated presentational attributes.

Key Takeaways

  • Role: <col> targets columns inside <colgroup> for styling.
  • span: one element can cover several consecutive columns.
  • CSS: backgrounds and width work best; align cells with selectors, not col inheritance.
  • Legacy: drop width, align, bgcolor, and friends.

One line: put void <col> tags in a span-free <colgroup>, then style columns with CSS.

Default CSS Settings

col does not render its own box like a cell. Typical mapping:

default.css
col {
  display: table-column;
}

Visible look comes from limited CSS you apply (background, width, and so on) and from the cells in that column.

Frequently Asked Questions

The col element defines one or more columns inside a colgroup so you can style those columns (for example background or width) without repeating styles on every cell.
Only as a child of colgroup, and that colgroup must not have a span attribute. Place colgroup near the start of the table (after caption if present).
span is a positive integer that says how many consecutive columns this col covers. The default is 1.
col has no descendants, so properties that rely on inheritance (like text-align or vertical-align set on col) do not style the cells. Style td/th with nth-of-type selectors instead.
No. Those attributes are deprecated. Use CSS width, background-color, and cell text-align / vertical-align instead.
Yes. It has a start tag only — no end tag and no content inside.

Next: colgroup

Group columns and host col elements in an HTML table.

colgroup tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful