Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

column-width — preferred column width

The column-width property specifies a preferred column size in a multi-column layout. It does not guarantee an exact width: the browser adjusts columns to the available space and gaps.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

column-width: auto | <length [0,∞]>;

column-width specifies the optimal inline size of a column. For horizontal text this is its width; for vertical text it is its vertical dimension. The property applies to block containers except table wrapper boxes and is not inherited.

The initial value, auto, leaves sizing to other properties, such as column-count. A length such as 180px or 12em sets the preferred size. Percentages and negative values are invalid; 0 is valid, but used values are clamped to a minimum of 1px.

Columns can become wider to fill the container, or narrower if the available space is smaller than the specified length. column-gap affects how many columns fit. When both column-count and column-width are non-auto, the number in column-count is an upper limit.

In the example, the container is 420px wide with a 20px gap: two columns each receive (420px - 20px) / 2 = 200px, despite the 180px declaration. The property's computed value therefore need not match the actual column size.

Examples

<!doctype html>
<meta charset="utf-8">
<title>column-width</title>
<style>
  .columns {
    width: 420px;
    column-width: 180px;
    column-count: auto;
    column-gap: 20px;
    column-fill: balance;
    font: 16px/20px monospace;
  }
  .item {
    height: 20px;
    break-inside: avoid;
    background: #e0eaff;
  }
</style>
<div class="columns">
  <div class="item">A</div>
  <div class="item">B</div>
  <div class="item">C</div>
  <div class="item">D</div>
</div>

Result

Expected layout: two 200px columns separated by 20px; A and B in the first column, C and D in the second.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources