<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/highlighting-columns-in-html-tables-pfcbhyghu" -->

---
title: Highlighting columns in HTML tables | daily.dev
description: The `col` and `colgroup` HTML elements can be used to style entire table columns with CSS, even though HTML tables are structurally row-based. By adding a...
canonical: https://daily.dev/posts/highlighting-columns-in-html-tables-pfcbhyghu
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Highlighting columns in HTML tables | daily.dev
og:description: The `col` and `colgroup` HTML elements can be used to style entire table columns with CSS, even though HTML tables are structurally row-based. By adding a...
og:url: https://daily.dev/posts/highlighting-columns-in-html-tables-pfcbhyghu
og:image: https://api.daily.dev/og/posts/pfCbHygHU.png
og:image:alt: Highlighting columns in HTML tables
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Highlighting columns in HTML tables

**[Manuel Matuzović](https://daily.dev/sources/matuzo)** · 3 min read · 0 upvotes · 0 comments

## Summary

The `col` and `colgroup` HTML elements can be used to style entire table columns with CSS, even though HTML tables are structurally row-based. By adding a class to a `col` element, background styles apply to all cells in that column. More interestingly, adding `id` attributes to `col` elements and using the CSS `:target` pseudo-class lets users click column headings to highlight a specific column — and the highlighted state is shareable via URL fragment. Accessibility caveats are noted: links in table headings need better labels, and this technique is visual-only with no semantic column highlighting.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.matuzo.at/blog/highlighting-columns>

## Similar posts on daily.dev

- [Accessible \(I Think\) Split-Cell Table Headers](https://daily.dev/posts/accessible-i-think-split-cell-table-headers-pimkau8of) · Eric Meyer — meyerweb.com · 0 upvotes · 0 comments
- [The different ways to use CSS :has\(\), with examples](https://daily.dev/posts/the-different-ways-to-use-css-has-with-examples-olvwfjtu1) · LogRocket · 10 upvotes · 0 comments

---

Tags: [#css](https://daily.dev/tags/css), [#html](https://daily.dev/tags/html)

[View this post on daily.dev](https://daily.dev/posts/highlighting-columns-in-html-tables-pfcbhyghu)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Highlighting columns in HTML tables","url":"https://daily.dev/posts/highlighting-columns-in-html-tables-pfcbhyghu","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/highlighting-columns-in-html-tables-pfcbhyghu"},"datePublished":"2026-06-22T14:42:48.998Z","dateModified":"2026-06-22T14:45:36.592Z","description":"The `col` and `colgroup` HTML elements can be used to style entire table columns with CSS, even though HTML tables are structurally row-based. By adding a...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4574504c99ec6f4df4ae051cfe2c858b?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4574504c99ec6f4df4ae051cfe2c858b?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Manuel Matuzović","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Manuel Matuzović","logo":"https://media.daily.dev/image/upload/s--EstFG5yE--/f_auto,q_auto/v1782139307/logos/matuzo","url":"https://daily.dev/sources/matuzo"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/highlighting-columns-in-html-tables-pfcbhyghu","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"css,html","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Manuel Matuzović","item":"https://daily.dev/sources/matuzo"},{"@type":"ListItem","position":3,"name":"Highlighting columns in HTML tables"}]}
```

