π What is columns?
The columns property is a shorthand that allows you to define multi-column layouts effortlesslyβsimilar to newspaper or magazine layouts. It combines two longhand properties:
- column-width β Ideal width of each column
- column-count β Number of columns desired
Note
β Automatically balances column height
β No need for flex or grid
π― Why Use columns?
- Create magazine-like layouts
- Make text easier to read on large screens
- Automatically evenly distribute content
- No need for extra markup to create multiple columns
π Syntax
columns Syntax
columns: <column-width> || <column-count>;Either value can be omitted β the browser will calculate the missing side.
π¨ Example 1 β Set Column Count
3 Columns Example
.article {
columns: 3;
}The text will flow into 3 evenly sized columns.
π¨ Example 2 β Set Column Width
Column Width Example
.article {
columns: 200px;
}The browser will add as many 200px columns as can fit.
π¨ Example 3 β Width + Count Together
Combined Example
.article {
columns: 250px 3;
}Means: Try to make 3 columns, each ideally 250px wide. The browser adjusts based on available space.
π Related Multi-Column Properties
| Property | Description |
|---|---|
| column-gap | Spacing between columns |
| column-rule | Border line between columns |
| column-span | Make an element span across all columns |
| column-fill | Balance or not balance the column heights |
π§ͺ Example 4 β Adding Column Gap & Rule
Gap + Rule
.article {
columns: 3;
column-gap: 2rem;
column-rule: 1px solid #ccc;
}Creates professional magazine-style separation.
π§ͺ Example 5 β Headline Spanning All Columns
column-span Example
h2 {
column-span: all;
}Perfect for section headings inside multi-column text.
π§ How Columns Behave
- Browser automatically balances column heights
- Content flows left-to-right, top-to-bottom (depends on writing mode)
- No extra wrappers needed β columns are generated purely by CSS
- Columns adjust responsively as screen size changes
Note
π± Responsive Columns Example
Responsive Columns
.article {
columns: 300px;
}
@media (max-width: 700px) {
.article {
columns: 1;
}
}On wide screens β multiple columns On small screens β single column for readability
β οΈ Common Mistakes
- β Expecting columns to align like grid/flex items
- β Trying to position elements inside each column manually
- β Forgetting that images and long unbreakable content may overflow
- β Using columns for interactive card layouts β Not recommended
Note
π₯ Summary
The columns shorthand makes it extremely simple to create multi-column text layouts similar to magazines and newspapers. Combined with properties like column-gap and column-rule, you can design elegant, readable, and professionally styled content areas.
Learn more βMDN Docs π