๐Ÿ“š CSS column-rule โ€” Complete Tutorial

๐ŸŒ 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.

>>โ€œcolumn-rule = width + style + color โ€” all in one clean declaration.โ€

Note

โœ” Only works with multi-column layout
โœ” 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

Column rules appear only between columns โ€” never before the first or after the last.

๐Ÿงช 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

Always specify at least:column-rule: width style.

๐Ÿ”ฅ 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.

>>โ€œA well-styled column rule separates content cleanly and elevates the reading experience.โ€

Learn more โ†’ MDN Docs ๐Ÿ“˜