CSS columns Property

The columns property is a CSS shorthand that sets the preferred column width and column count of a multi-column container in a single declaration.

It combines the column-width and column-count properties. You can specify a preferred width, a column count, or both, allowing the browser to arrange flowing content into columns based on the available space.

The shorthand is useful for articles, documentation, reference lists, and other content that benefits from automatic multi-column formatting.

columns Syntax

The columns shorthand accepts one or two values representing column-width and column-count.

selector {
  columns: 250px 3;
}

General Syntax

selector {
  columns: <column-width> || <column-count>;
}

The double vertical bar (||) indicates that one or both components can be provided, in either order.

Column Count Only

.article {
  columns: 3;
}

Column Width Only

.article {
  columns: 250px;
}

Width and Count

.article {
  columns: 250px 3;
}

Reversed Value Order

.article {
  columns: 3 250px;
}

Automatic Values

.article {
  columns: auto;
}
.article {
  columns: auto 3;
}
.article {
  columns: 250px auto;
}

CSS-Wide Keywords

.article {
  columns: inherit;
}
.article {
  columns: initial;
}
.article {
  columns: unset;
}
.article {
  columns: revert;
}
.article {
  columns: revert-layer;
}

Each CSS-wide keyword must be used as the value of the entire shorthand declaration rather than combined with another component.

Property Values

The columns shorthand accepts the valid values of its two longhand properties.

Value Description
auto Uses automatic values for both column-width and column-count.
3 Requests three columns and sets the preferred column width to auto.
250px Sets the preferred column width to 250 pixels and the column count to auto.
250px 3 Requests columns approximately 250 pixels wide, with a maximum count of three under normal sizing conditions.
3 250px Equivalent to 250px 3.
18rem 2 Uses a preferred width relative to the root font size and a requested count of two.
auto 4 Uses an automatic preferred width and requests four columns.
240px auto Uses a 240-pixel preferred width and lets the browser determine the column count.

CSS-Wide Keywords

Value Description
inherit Inherits both longhand values from the parent element.
initial Resets both longhand properties to auto.
unset Resets both longhand properties to auto because neither is inherited.
revert Reverts both longhand properties according to cascade origin rules.
revert-layer Reverts both longhand properties according to cascade layer rules.

Property Characteristics

Characteristic Value
Property type Shorthand
Longhand properties column-width, column-count
Initial values auto for both properties
Inherited No
Applies to Multi-column containers
Computed value Determined individually for each longhand property
Animation type Determined by the longhand properties
Percentages Not accepted for the width component
Layout effect Controls preferred column width and column count

Because columns is a shorthand, its computed values and animation behavior follow the definitions of column-width and column-count.

How It Works

The columns property tells the browser how to divide content into columns using the preferred width, requested count, or both.

Step 1: Create a Container

.article {
  width: 900px;
}

Step 2: Specify the Columns

.article {
  width: 900px;
  columns: 250px 3;
}

Step 3: Add Spacing

.article {
  width: 900px;
  columns: 250px 3;
  column-gap: 30px;
}

Step 4: Calculate the Column Arrangement

The browser determines how many preferred-width columns fit while respecting the requested count and the space occupied by column gaps.

In this example, three columns can fit within the 900-pixel container.

Step 5: Distribute Available Width

With two 30-pixel gaps, 840 pixels remain for the three columns. Each column receives an actual width of 280 pixels.

Step 6: Flow the Content

The browser distributes the content through the generated columns according to multi-column fragmentation and filling rules.

Important Distinction

The shorthand does not guarantee that every column will be exactly 250 pixels wide. The specified length is a preferred width, and the browser can adjust the actual column dimensions.

Column Count Only

When the columns shorthand contains only a positive integer, it sets column-count and resets column-width to auto.

Two Columns

.article {
  columns: 2;
}

Three Columns

.article {
  columns: 3;
}

Four Columns

.article {
  columns: 4;
}

Equivalent Longhand Properties

.article {
  column-width: auto;
  column-count: 3;
}

How the Width Is Determined

The browser divides the available width among the requested columns after accounting for the gaps.

Example with a Gap

.article {
  columns: 3;
  column-gap: 25px;
}

When to Use

Use a count-only declaration when you want a specific number of columns and are comfortable allowing their widths to adjust to the container.

For narrow screens, consider reducing the count with a media query to avoid excessively narrow columns.

Column Width Only

When the columns shorthand contains only a positive length, it sets column-width and resets column-count to auto.

Pixel Width

.article {
  columns: 250px;
}

Relative Width

.article {
  columns: 18rem;
}

Font-Relative Width

.article {
  columns: 20em;
}

Equivalent Longhand Properties

.article {
  column-width: 250px;
  column-count: auto;
}

Automatic Column Count

The browser creates as many columns as fit based on the preferred width and available space.

Example with a Gap

.article {
  columns: 240px;
  column-gap: 30px;
}

When to Use

Use a width-only declaration when maintaining an approximate reading width is more important than controlling the number of columns.

This approach is particularly useful for responsive content because the browser can reduce the number of columns automatically as the container becomes narrower.

Width and Count Together

Providing both a length and a positive integer lets you set a preferred column width and limit the number of columns.

Basic Example

.article {
  columns: 250px 3;
}

Equivalent Longhand Properties

.article {
  column-width: 250px;
  column-count: 3;
}

Reversed Order

.article {
  columns: 3 250px;
}

The order of the width and count components does not change their meaning.

Two-Column Maximum

.article {
  columns: 220px 2;
}

Four-Column Maximum

.article {
  columns: 200px 4;
}

Narrow Containers

When the container cannot accommodate the requested count at the preferred width, the browser can use fewer columns.

Wide Containers

When the container has additional space, the browser can expand the columns rather than creating more than the requested count in a normal column row.

When to Use

Use both values when you want responsive column sizing while preventing the layout from generating too many columns.

Using auto

The auto keyword can be used for either longhand component or for both components.

Both Components Automatic

.article {
  columns: auto;
}

This resets both column-width and column-count to auto.

Automatic Width

.article {
  columns: auto 3;
}

The browser calculates the column width from the available space and the requested count of three.

Automatic Count

.article {
  columns: 250px auto;
}

The browser determines the number of columns using the preferred width of 250 pixels.

Explicit Reset

.article {
  columns: 250px 3;
}
.article.normal-flow {
  columns: auto;
}

The second rule restores both components to their initial values, removing the multi-column arrangement established by the first rule.

When to Use

Use auto when you want the browser to determine one component from the other or reset the shorthand to its default behavior.

Shorthand Reset Behavior

Like other CSS shorthands, columns resets any omitted longhand component to its initial value.

Resetting column-count

.article {
  column-count: 4;
  columns: 250px;
}

The final declaration sets column-width: 250px and resets column-count to auto.

Resetting column-width

.article {
  column-width: 200px;
  columns: 3;
}

The final declaration sets column-count: 3 and resets column-width to auto.

Overriding One Component

.article {
  columns: 250px 3;
  column-width: 300px;
}

The later longhand declaration changes only the preferred width. The count remains three.

Overriding the Count

.article {
  columns: 250px 3;
  column-count: 2;
}

The count becomes two, while the preferred width remains 250 pixels.

Resetting Both Components

.article {
  columns: 250px 3;
  columns: initial;
}

Other Column Properties Are Not Reset

.article {
  column-gap: 30px;
  column-rule: 2px solid #cccccc;
  columns: 250px 3;
}

The shorthand does not reset column-gap, column-rule, column-fill, or column-span.

Practical Consideration

Use individual longhand declarations when changing only one component of an existing multi-column layout.

Column Sizing and Distribution

The browser uses the available container width, preferred column width, requested count, and column gaps to calculate the actual column arrangement.

Fixed Container Example

.article {
  width: 900px;
  columns: 250px 3;
  column-gap: 30px;
}

Preferred Width Calculation

Three columns at the preferred width, plus two gaps, require 810 pixels.

/* (3 * 250px) + (2 * 30px) = 810px */

Actual Column Width

Because the container is 900 pixels wide, the browser distributes the available width across the three columns.

/* (900px - 60px) / 3 = 280px */

Narrower Container

.article {
  width: 500px;
  columns: 250px 3;
  column-gap: 30px;
}

Only one preferred-width column fits under the normal column sizing rules, so the browser can use a single column rather than forcing three narrow columns.

Wider Container

.article {
  width: 1200px;
  columns: 250px 3;
  column-gap: 30px;
}

The browser can use three wider columns because the specified count limits the number of columns in a normal column row.

Width-Only Layout

.article {
  width: 1200px;
  columns: 250px;
  column-gap: 30px;
}

Without a specified count, the browser can create additional columns as space permits.

Important Distinction

The shorthand controls preferred sizing and count constraints. It does not directly set the final pixel width of every column.

Column Gaps and Rules

The columns shorthand does not include column gaps or decorative rules. These must be specified separately.

Column Gap

.article {
  columns: 250px 3;
  column-gap: 30px;
}

Column Rule

.article {
  columns: 250px 3;
  column-rule: 2px solid #cccccc;
}

Gap and Rule Together

.article {
  columns: 250px 3;
  column-gap: 30px;
  column-rule: 2px solid #cccccc;
}

Default Gap

.article {
  columns: 3;
  column-gap: normal;
}

In multi-column layout, normal generally corresponds to a gap of 1em.

Rule Placement

The column rule is drawn within the gap between adjacent columns. Its width does not reserve additional layout space.

Rule Visibility

A column rule requires a visible style, such as solid, to appear. The initial column-rule-style value is none.

Practical Consideration

Use column gaps for spacing and column rules for visual separation. Neither is included in the columns shorthand.

Column Filling and Balancing

The column-fill property controls how content is distributed among columns, independently of the columns shorthand.

Balanced Columns

.article {
  columns: 250px 3;
  column-fill: balance;
}

The balance value asks the browser to distribute content across columns as evenly as possible, subject to fragmentation constraints.

Sequential Filling

.article {
  height: 350px;
  columns: 250px 3;
  column-fill: auto;
}

With a definite height, auto generally fills columns sequentially rather than balancing their heights.

Default Filling Behavior

The initial value of column-fill is balance.

Content Overflow

When a height-constrained multi-column container cannot accommodate all its content, additional overflow columns may be generated according to the fragmentation rules.

Shorthand Independence

Changing columns does not reset column-fill.

Practical Consideration

Use columns to establish horizontal column sizing and column-fill to influence vertical content distribution.

Spanning Elements

The column-span property allows eligible block-level elements to extend across all columns of a multi-column container.

Basic Example

.article {
  columns: 250px 3;
  column-gap: 30px;
}
.article h2 {
  column-span: all;
}

Example HTML

<article class="article">
  <h2>HTML Fundamentals</h2>
  <p>HTML defines the structure of web documents.</p>
  <p>Semantic elements describe the purpose of content.</p>
  <h2>CSS Fundamentals</h2>
  <p>CSS controls the visual presentation of HTML elements.</p>
  <p>Layout properties arrange content within the page.</p>
</article>

Spanning Behavior

The headings span the available width, while the paragraphs below each heading flow through columns according to the shorthand settings.

Separate Column Sections

Each spanning heading divides the content into a separate multi-column section.

Column Rules

Column rules do not extend through spanning elements.

Practical Consideration

Use spanning headings when a multi-column document needs clear full-width section boundaries.

Calculated Values and Variables

The width component of the columns shorthand can use CSS math functions and custom properties that resolve to valid lengths.

Using calc()

.article {
  columns: calc(200px + 2rem) 3;
}

Using clamp()

.article {
  columns: clamp(200px, 25vw, 350px) 3;
}

Using min()

.article {
  columns: min(300px, 30vw) 3;
}

Using max()

.article {
  columns: max(200px, 20vw) 3;
}

CSS Custom Properties

:root {
  --preferred-column-width: 240px;
  --maximum-columns: 3;
}
.article {
  columns: var(--preferred-column-width) var(--maximum-columns);
}

Component-Specific Variables

.article {
  --column-size: 18rem;
  --column-limit: 2;
  columns: var(--column-size) var(--column-limit);
}

Invalid Calculated Widths

The width component must resolve to a valid positive length. A percentage or nonpositive length is not accepted.

Count Requirements

The count component must be auto or a positive integer. Fractional values such as 2.5 are invalid.

Practical Consideration

Use custom properties when several components share the same column settings or when a layout needs consistent adjustments at different breakpoints.

Responsive Layouts

The columns shorthand supports responsive multi-column layouts by allowing the browser to adjust the number and width of columns.

Automatic Responsive Columns

.article {
  columns: 240px;
  column-gap: 30px;
}

The browser determines how many preferred-width columns fit within the available space.

Responsive Layout with a Maximum Count

.article {
  columns: 240px 3;
  column-gap: 30px;
}

The browser can use fewer columns on narrow screens while limiting the normal column count to three.

Desktop Layout

.article {
  columns: 280px 3;
  column-gap: 30px;
}

Tablet Layout

@media (max-width: 900px) {
  .article {
    columns: 240px 2;
    column-gap: 24px;
  }
}

Mobile Layout

@media (max-width: 600px) {
  .article {
    columns: 1;
  }
}

Responsive Width with clamp()

.article {
  columns: clamp(200px, 25vw, 320px) 3;
  column-gap: 25px;
}

Container Queries

.article-wrapper {
  container-type: inline-size;
}
.article {
  columns: 240px 3;
}
@container (max-width: 600px) {
  .article {
    columns: 1;
  }
}

Container queries allow the column arrangement to respond to the available space within a component rather than the entire viewport.

Practical Consideration

For text-heavy layouts, use a preferred width that preserves readable line lengths and reduce the number of columns when space becomes limited.

Practical Uses

The columns shorthand is useful for content that should flow naturally into multiple columns without manually assigning items to individual tracks.

Article Content

.article-content {
  columns: 18rem 3;
  column-gap: 2rem;
}

Documentation Sections

.documentation {
  columns: 260px 2;
  column-gap: 30px;
}

Reference Lists

.reference-list {
  columns: 220px;
  column-gap: 25px;
}

Glossaries

.glossary {
  columns: 240px 3;
  column-gap: 30px;
}

Link Collections

.link-collection {
  columns: 180px;
  column-gap: 20px;
}

Avoiding Split List Items

.reference-list li {
  break-inside: avoid;
}

The break-inside property can help keep individual list items together within a column, subject to fragmentation constraints.

Print Layouts

@media print {
  .article-content {
    columns: 180pt 2;
    column-gap: 18pt;
  }
}

When Not to Use

Multi-column layout is intended for flowing content. Use CSS Grid when items require precise placement in rows and columns, or Flexbox when arranging items along a main axis.

columns Example

The following example compares three ways to use the columns shorthand: a column count, a preferred width, and both values together.

Resize the browser window to see how the width-based layouts adjust to the available space.

<div class="columns-demo">
  <div class="columns-example">
    <h3>columns: 2;</h3>
    <div class="columns-content columns-count">
      <p>HTML defines the structure of web pages using elements such as headings, paragraphs, and links.</p>
      <p>CSS controls presentation, including typography, spacing, colors, and layout.</p>
      <p>Selectors identify elements, while declarations specify the styles applied to them.</p>
      <p>Responsive design helps content adapt to different screen sizes.</p>
    </div>
  </div>
  <div class="columns-example">
    <h3>columns: 180px;</h3>
    <div class="columns-content columns-width">
      <p>HTML defines the structure of web pages using elements such as headings, paragraphs, and links.</p>
      <p>CSS controls presentation, including typography, spacing, colors, and layout.</p>
      <p>Selectors identify elements, while declarations specify the styles applied to them.</p>
      <p>Responsive design helps content adapt to different screen sizes.</p>
    </div>
  </div>
  <div class="columns-example">
    <h3>columns: 180px 3;</h3>
    <div class="columns-content columns-both">
      <p>HTML defines the structure of web pages using elements such as headings, paragraphs, and links.</p>
      <p>CSS controls presentation, including typography, spacing, colors, and layout.</p>
      <p>Selectors identify elements, while declarations specify the styles applied to them.</p>
      <p>Responsive design helps content adapt to different screen sizes.</p>
    </div>
  </div>
</div>
.columns-demo {
  display: grid;
  gap: 20px;
}
.columns-demo .columns-example {
  padding: 15px;
  border: 1px solid #cccccc;
  background-color: #f8f9fa;
}
.columns-demo h3 {
  margin: 0 0 12px;
  font-size: 1.125rem;
}
.columns-demo .columns-content {
  column-gap: 25px;
  column-rule: 1px solid #cccccc;
}
.columns-demo .columns-content p {
  margin: 0 0 12px;
}
.columns-demo .columns-count {
  columns: 2;
}
.columns-demo .columns-width {
  columns: 180px;
}
.columns-demo .columns-both {
  columns: 180px 3;
}
@media (max-width: 600px) {
  .columns-demo .columns-content {
    columns: 1;
  }
}
Browser Result

columns: 2;

HTML defines the structure of web pages using elements such as headings, paragraphs, and links.

CSS controls presentation, including typography, spacing, colors, and layout.

Selectors identify elements, while declarations specify the styles applied to them.

Responsive design helps content adapt to different screen sizes.

columns: 180px;

HTML defines the structure of web pages using elements such as headings, paragraphs, and links.

CSS controls presentation, including typography, spacing, colors, and layout.

Selectors identify elements, while declarations specify the styles applied to them.

Responsive design helps content adapt to different screen sizes.

columns: 180px 3;

HTML defines the structure of web pages using elements such as headings, paragraphs, and links.

CSS controls presentation, including typography, spacing, colors, and layout.

Selectors identify elements, while declarations specify the styles applied to them.

Responsive design helps content adapt to different screen sizes.

The first example uses columns: 2, which requests two columns and allows their widths to adjust to the available space.

The second example uses columns: 180px, which requests columns approximately 180 pixels wide and lets the browser determine how many fit.

The third example uses columns: 180px 3, combining a preferred width with a maximum count of three under normal sizing conditions.

All three examples use the same column gap and decorative rule. Only the columns shorthand values change.

On narrow screens, the media query changes each example to a single-column layout.

Accessibility

Multi-column layouts can improve the organization of content, but column width, count, and reading order should be considered carefully.

Maintain Readable Line Lengths

Choose column widths that avoid excessively narrow or long lines of text.

Consider Browser Zoom

Test multi-column layouts at increased zoom levels. Reduce the number of columns when necessary to prevent cramped text and unnecessary horizontal scrolling.

Preserve Source Order

Multi-column layout changes visual presentation without changing the HTML source order. Assistive technologies generally follow the document structure.

Avoid Excessive Column Counts

Too many columns can make it difficult to follow content, particularly on smaller screens or when using magnification.

Provide Adequate Column Gaps

Use sufficient spacing between columns so readers can distinguish where one column ends and the next begins.

Responsive Layouts

Allow layouts to use fewer columns as available space decreases. A single column is often preferable on narrow screens.

Avoid Fixed Heights for Long Content

Fixed-height multi-column containers can produce horizontal overflow when additional columns are needed. Allow content to grow naturally when possible.

Test Real Content

Check layouts with realistic headings, paragraphs, links, lists, and other content to ensure the column arrangement remains usable.

Important Considerations

Keep the following points in mind when using the columns shorthand:

  • Purpose: Sets preferred column width and column count in one declaration.
  • Property type: Shorthand.
  • Longhand properties: column-width and column-count.
  • Initial values: Both longhand properties initially use auto.
  • Inheritance: Neither longhand property is inherited.
  • Valid width: auto or a positive CSS length.
  • Valid count: auto or a positive integer.
  • Value order: Width and count may appear in either order.
  • Single value: A single length sets the width; a single integer sets the count.
  • Omitted components: Any omitted component resets to its initial value.
  • Preferred width: The specified length is not a guaranteed exact column width.
  • Column count: The browser may use fewer columns when the preferred width cannot fit.
  • Count constraint: A specified count limits the normal number of columns.
  • Percentages: Not accepted as column-width values.
  • Invalid widths: Zero and negative lengths are not accepted.
  • Invalid counts: Zero, negative numbers, and fractional counts are not accepted.
  • Column gaps: Must be set separately with column-gap.
  • Column rules: Must be set separately with column-rule or its longhand properties.
  • Column filling: Controlled separately by column-fill.
  • Spanning elements: Controlled separately by column-span.
  • Calculated widths: CSS math functions can provide valid positive lengths.
  • Custom properties: Can store reusable width and count values.
  • Responsive behavior: Width-based layouts can automatically adjust the number of columns.
  • Animation: Follows the animation behavior of the longhand properties.
  • Accessibility: Maintain readable column widths, sufficient spacing, and logical content order.

Use columns when you want a concise way to define the width and number of columns in a multi-column layout. Use the individual longhand properties when you need to modify one component without resetting the other.

Browser Support

The columns shorthand is widely supported in modern browsers, including Chrome, Edge, Firefox, and Safari.

The standard unprefixed syntax is supported in current browsers.

Basic Example

.article {
  columns: 250px 3;
  column-gap: 30px;
}

Equivalent Longhand Properties

.article {
  column-width: 250px;
  column-count: 3;
  column-gap: 30px;
}

Compatibility Considerations

Older browsers sometimes required vendor-prefixed multi-column properties. Modern browsers support the standard unprefixed shorthand.

For current compatibility information, visit Can I Use? and search for columns.

Specifications

The columns shorthand is defined in CSS Multi-column Layout Module Level 1.

CSS Multi-column Layout Module Level 1

The specification defines the shorthand syntax, accepted values, reset behavior, and relationship between column-width and column-count.