CSS Reference ยท Multi-column and Fragmentation
The column-rule property
Reference for the CSS column-rule shorthand: draw a line between columns with width, style and color in one declaration, with live examples and usage notes.
The column-rule property draws a line between the columns of a multi-column container. It is a shorthand for column-rule-width, column-rule-style and column-rule-color, and it takes the same kind of values as a border.
The rule is drawn in the middle of the column gap. It does not take up any space of its own: widening the rule never moves the text.
.article { column-count: 3; column-gap: 2rem; column-rule: 2px solid #888; }
Try it
Syntax
column-rule: <'column-rule-width'> || <'column-rule-style'> || <'column-rule-color'>;
- Initial value:
medium none currentcolor(each longhand at its own initial value) - Applies to: multi-column containers
- Inherited: no
- Animatable: width and color are animatable; the style is not
- Computed value: the computed values of the three longhands
Values
| Value | Description |
|---|---|
<line-width> |
thin, medium, thick or a non-negative length such as 2px. |
<line-style> |
Any border style: none, hidden, dotted, dashed, solid, double, groove, ridge, inset or outset. |
<color> |
Any CSS color. Defaults to currentcolor, the text color. |
The three parts can be written in any order, and any of them can be left out.
Usage notes
- The style is required in practice. The initial style is
none, socolumn-rule: 2px #888draws nothing. Always include a style such assolid. - A rule only appears between columns that contain content. Empty columns, and the space after the last column, get no rule.
- It takes no space. The rule is painted over the gap. If the gap is narrower than the rule, the rule overlaps the text, so size the
column-gapgenerously. - Spanning elements. Rules stop at an element that uses
column-span: alland start again below it. - Grid and flexbox. The property is for multi-column containers only. Grid and flex containers have no rules; use borders or pseudo-elements there.
- Use a subtle color. A light gray rule separates columns without competing with the text. Check contrast if the rule carries meaning.
Browser support
Supported in all current major browsers for multi-column containers.
Related
column-rule-widthโ line thicknesscolumn-rule-styleโ line stylecolumn-rule-colorโ line colorcolumn-gapโ space between columnscolumnsโ column width and count- Lesson: Multi-column Layout