Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Multi-column and Fragmentation

The column-width property

Reference for the CSS column-width property: set the ideal minimum width of columns so the browser chooses how many fit, with a responsive example.

The column-width property gives the ideal width of each column in a multi-column container. The browser then fits as many columns of at least that width as it can, and widens them slightly to use up the leftover space. It is the responsive way to make columns: more columns on wide screens, a single column on narrow ones, with no media queries.

CSS
.text {
  column-width: 16rem;
}

Try it

Columns that adapt to the width

Syntax

CSS
column-width: auto | <length [0,โˆž]>;
  • Initial value: auto
  • Applies to: non-replaced block containers (except table wrappers), flex containers and grid containers
  • Inherited: no
  • Animatable: yes, as a length
  • Computed value: the absolute length, or auto

Values

Value Description
auto No preferred width; the number of columns comes from column-count.
<length> The ideal minimum width. Must not be negative. Percentages are not allowed.

Usage notes

  • It is a minimum. Actual columns are as wide as or wider than the value, apart from the single-column case in a very narrow container.
  • Use rem or ch so column width follows the font size: column-width: 20rem.
  • Combine with column-count (or the columns shorthand) to cap the number of columns.
  • Gaps count. The calculation includes column-gap, so a large gap leaves fewer columns.
  • Items wider than a column (images, code, tables) overflow it; give them max-width: 100%.

Browser support

Supported in all current browsers.