CSS Reference ยท Selectors
The column combinator (A || B)
Reference for the CSS column combinator (||), which selects table cells that belong to a column. Specified, but with very limited browser support.
The column combinator, written ||, is meant to select table cells by the column they belong to. col.price || td would match every <td> in the column described by <col class="price">, even though the cells are not descendants of the <col>.
Limited support: at the time of writing, no major browser ships a working implementation, so a rule using || is treated as invalid and ignored. Do not depend on it. This page is short on purpose.
col.price || td { text-align: right; }
Try it
Syntax and arguments
col.name || td { } /* cells in the column(s) of col.name */
| Part | Description |
|---|---|
A |
A selector for a <col> (or <colgroup>) element. |
|| |
The column combinator. |
B |
A selector for cells in the columns that A covers. |
Specificity would be the sum of both sides. Cells that span several columns belong to each of them.
Usage notes
- Not usable yet. Browsers that do not know the combinator discard the entire rule, including every other selector in the same selector list. Never put
||in a list with working selectors. - Today's options. Add classes to the cells, use
td:nth-child(n)or:nth-of-type, or style the column box through<col>. Only a few properties apply tocolandcolgroup:border,background,widthandvisibility. - Why it exists. Cell-to-column relationships are not a parent-child relationship in the DOM, so no existing combinator can express them.
- Related syntax. The same two bars also appear in grammars as the "double bar" combinator in value definitions; that is unrelated to selectors.
Browser support
Limited: not usable in production browsers. Check current compatibility data before relying on it.