๐ What Is column-rule?
The column-rule property is a **shorthand** used to define thewidth, style, and color of the vertical line that appears between text columns in a CSS Multi-Column Layout. It behaves similarly to the border shorthand but applies **only between columns**, not around the container.
Note
โ Expands into:
ย ย โข column-rule-width
ย ย โข column-rule-style
ย ย โข column-rule-color
๐ฆ Syntax
column-rule syntax
column-rule: <width> <style> <color>;Only style is required for the rule to appear; width & color are optional but usually included.
๐ 1. Basic Example โ Simple Solid Rule
Basic solid rule
.content {
column-count: 2;
column-rule: 2px solid #333;
}Creates a 2px solid dark gray divider between columns.
๐ 2. Using Dotted Column Rule
Dotted rule
.article {
column-count: 3;
column-rule: 3px dotted #4a90e2;
}Produces a dotted divider โ good for soft or playful design.
๐ 3. Dashed Column Rule
Dashed
.post {
column-count: 2;
column-rule: 3px dashed crimson;
}Works well to add structure without being too bold.
๐ 4. Double Rule โ Elegant Magazine Look
Double rule
.mag {
column-count: 3;
column-rule: 4px double #555;
}Gives a premium, print-style feel to multi-column content.
๐ 5. Using Only Style (Width & Color Default)
Only style
.simple {
column-count: 2;
column-rule: solid; /* width defaults to medium, color defaults to currentcolor */
}Quick and simple, but not recommended for precise control.
๐ 6. Using Custom Width Units
Custom widths
.wide-rule {
column-count: 2;
column-rule: 0.4rem solid orange;
}Relative units allow responsive scaling.
๐ 7. Combine With column-gap
Rule + Gap
.layout {
column-count: 3;
column-gap: 40px;
column-rule: 4px solid #999;
}Larger gaps provide room for thicker rules.
๐ 8. The Rule Appears Between Columns Only
Column rules are inner dividers:
No rule on edges
/* This will NEVER draw a rule on the left or right edge */
.container {
column-count: 3;
column-rule: 3px solid #000;
}Note
๐งช Real-World Examples
1๏ธโฃ Newspaper / Magazine Layout
Newspaper
.news {
column-count: 3;
column-gap: 30px;
column-rule: 2px solid #ccc;
}2๏ธโฃ Multi-Column Blog Layout
Blog
.blog {
column-count: 2;
column-rule: 3px dashed #ff9800;
}3๏ธโฃ Print-Style Chapter Layout
Print layout
@media print {
.chapter {
column-count: 2;
column-rule: 1px solid black;
}
}โ ๏ธ Common Mistakes
- โ Setting only width โ rule won't appear without style
- โ Expecting rule outside the container edges (it doesn't show there)
- โ Using very thick rules with small gaps (cramped layout)
- โ Forgetting that rules do not affect layout flow (purely decorative)
Note
๐ฅ Summary
The column-rule shorthand is the cleanest way to style the vertical dividers between columns in a multi-column layout. With just one line, you control thickness, line type, and color. This property adds structure, readability, and beauty to text-heavy designs.
Learn more โ MDN Docs ๐