π¨ CSS column-rule-color β Complete Tutorial
π What Is column-rule-color?
The column-rule-color property sets thecolor of the line (called a column rule) that appears between columns in a CSS Multi-Column Layout. Think of it like a border color, but specifically for columns.
>>βUse column-rule-color to highlight or style the dividing lines between your multi-column text.β
Note
β Works only with multi-column layout
β Requires column-rule-style and/or column-rule-width to be visible
β Similar to setting border colors
β Requires column-rule-style and/or column-rule-width to be visible
β Similar to setting border colors
π¦ Syntax
column-rule-color syntax
column-rule-color: <color>;| Value | Description |
|---|---|
| <color> | Any CSS color value (hex, rgb, hsl, named colors, etc.) |
π 1. Basic Example β Set Column Rule Color
Simple colored column rule
.content {
column-count: 3;
column-rule-style: solid;
column-rule-width: 3px;
column-rule-color: #4a90e2; /* Blue rule */
}A blue vertical line appears between the 3 columns.
π 2. Using RGBA for Transparent Column Rules
Transparent rule
.article {
column-count: 2;
column-rule: 4px solid rgba(0, 0, 0, 0.3);
}Creates a soft, semi-transparent divider.
π 3. Using HSL Colors
HSL rule color
.magazine {
column-count: 3;
column-rule-width: 2px;
column-rule-style: dashed;
column-rule-color: hsl(340, 80%, 60%);
}HSL is great for visually consistent themes.
π 4. Customizing Column Rule Without Separate Properties
Shorthand version
.content {
column-count: 3;
column-rule: 5px dotted crimson;
}column-rule shorthand includes width, style, and color.
π 5. Gradient-Like Divider Using Repeating Linear Gradient
Fancy gradient rule
.fancy {
column-count: 3;
column-gap: 40px;
column-rule-width: 6px;
column-rule-style: solid;
column-rule-color: transparent;
background: repeating-linear-gradient(
to right,
#0000 0,
#0000 1px,
#ff6b6b 1px,
#ff6b6b 3px
);
}Creates artistic rules using background tricks.
π 6. Using CSS Variables for Rule Color
Variables
:root {
--rule-color: #8e44ad;
}
.text {
column-count: 2;
column-rule: 3px solid var(--rule-color);
}Makes theme updates easy.
π§ͺ Real-World Examples
1οΈβ£ Magazine Layout
Magazine style
.magazine {
column-count: 3;
column-gap: 40px;
column-rule-width: 2px;
column-rule-style: solid;
column-rule-color: #ccc;
}2οΈβ£ Blog Content Divider
Blog columns
.blog-content {
column-count: 2;
column-rule: 2px solid #ff9800;
}3οΈβ£ Fancy Editorial Layout
Editorial
.editorial {
column-count: 4;
column-gap: 60px;
column-rule: 5px double #4caf50;
}β οΈ Common Mistakes
- β Setting column-rule-color without width or style β rule not visible
- β Expecting rule to appear outside the container (it stays inside columns)
- β Using thick rules with small column-gaps β bad readability
Note
A rule only appears between columns β not before the first or after the last.
π₯ Summary
The column-rule-color property controls the color of the dividing line between columns in a multi-column layout. Itβs often used with column-rule-width andcolumn-rule-style to create elegant and readable layouts.
>>βThe column rule color subtly guides the readerβs eye across multi-column text.β
Learn more βMDN Docs π