CSS Reference ยท Multi-column and Fragmentation
The columns property
Reference for the CSS columns shorthand: set column-width and column-count together to flow text into newspaper-style columns, with live examples.
The columns property is the shorthand for column-width and column-count. It makes an element flow its content into several columns, like a newspaper. Text fills the first column to the bottom, then continues at the top of the next.
The two values can come in either order, since one is a length and the other an integer.
CSS
article { columns: 3 14rem; column-gap: 2rem; }
Try it
Syntax
CSS
columns: <'column-width'> || <'column-count'>; columns: auto;
- Initial value:
auto auto - Applies to: non-replaced block containers (except table wrapper boxes), flex containers and grid containers
- Inherited: no
- Animatable: yes (as its longhands: width as a length, count as an integer)
- Computed value: as each longhand
Values
| Value | Description |
|---|---|
<length> |
The ideal minimum width of each column (column-width). |
<integer> |
The maximum number of columns (column-count) when combined with a width. |
auto |
Either part left to the browser. |
3 14rem |
At most 3 columns, each at least about 14rem wide; fewer columns are used when space is short. |
Usage notes
- Count plus width means "up to". With both set,
column-countis a limit; the browser chooses the number of columns that fit the width. - Width alone (
columns: 16rem) is the most responsive choice: as many columns as fit. - Gaps and rules come from
column-gap(default1em) andcolumn-rule. - Avoid breaking items such as cards with
break-inside: avoid. - Long articles are tiring. On screens, columns that force the reader to scroll back up to the top are hard to read; use them for short blocks like lists, footers or galleries.
- Set
columnson short content only if heights are bounded. In a container of fixed height content overflows sideways into extra columns. - Spanning headings can cross all columns with
column-span: all.
Browser support
Supported in all current browsers.
Related
column-countandcolumn-width- the longhandscolumn-fill- balancingcolumn-gap- spacing- Lesson: Multi-column Layout