CSS
๐ฏ CSS column-rule Property
The column-rule CSS shorthand property defines the full appearance of the vertical separator line between columns in a multi-column layout in a single declaration.
It combines width, style, and color of the column divider, making multi-column styling faster and cleaner.
๐น Why Use column-rule?
-
Benefits
- Defines column separator line in one line.
- Improves readability in multi-column layouts.
- Reduces repetitive CSS code.
- Common in newspaper and magazine-style designs.
๐งฉ Basic Usage
The following example creates a red solid separator line between three columns.
CSS
p {
column-count: 3;
column-gap: 20px;
column-rule: 2px solid red;
}
This creates a 3-column layout with a 2px solid red line between each column.
๐น column-rule Components
- column-rule-width โ Thickness of the line
- column-rule-style โ Style of the line (solid, dashed, dotted, etc.)
- column-rule-color โ Color of the line
๐น column-rule Values
- 2px solid red โ Example shorthand usage
- initial โ Resets to default value
- inherit โ Inherits value from parent element
๐ก Practical Example
CSS
.article {
column-count: 3;
column-gap: 25px;
column-rule: 1px dashed #3498db;
}
This example creates a multi-column layout with a dashed blue separator line between columns.
-
๐ง Summary
- column-rule is a shorthand property for column divider styling.
- It combines width, style, and color in one declaration.
- Makes multi-column CSS cleaner and easier to manage.
- Widely used in modern article and magazine layouts.
