Column-count - Property CSS

column-count

Summary of characteristics of the column-count property

Quick description
Sets the number of columns, in a multi-column layout.
Status
Standard
Applies to
Block containers except table container.
Usable for
HTML
Predefined values
auto
Percentages
Not applicable.
Initial value
auto
Inherited by default
No.
Integer: during an animation, the column-count property passes from one integer to another, without transition.
W3C Module
CSS Multi-column Layout Module
 🡇  
 🡅  
Document status: WD (Working Draft)

Document status: CR (Candidate Recommendation)

Syntax diagram of column-count.

column-count - Syntax DiagramSyntax diagram of the column-count CSS property. See stylescss.free.fr for details. auto auto integer integercolumn-count:;column-count:;
Syntax diagram of the column-count property.
The links in the diagram provide more details about the values.

In the diagram, the bold terms are the predefined words of CSS, the other terms are described below:

  • integer is an integer equal to or greater than 1.

Description of the column-count property.

column-count defines the number of columns in a multi-column layout. This property works in conjunction with the width of the columns (see column-width) :

  • If column-width is not defined or has the value auto, the number of columns is exactly that defined by column-count.
  • If the value of column-width is set, column-count then indicates the maximum number of columns. The number of columns may therefore be smaller to allow their display in the requested width.

If forced column breaks exist in the content of the element, they can cause the creation of more columns than expected by column-count. Reminder: forced column breaks are defined by the properties break-before and break-after .

For a general presentation of column layouts, refer to the explanations on the property page columns.

Values for column-count.

  • column-count: auto;

    Default value. The number of columns is determined from the width of the columns (see column-width). If the latter is not defined, the number of columns is equal to 1.

  • column-count: 3;

    A number without a unit, greater than zero.

  • column-count: initial; (auto) column-count: inherit; column-count: revert; column-count: revertLayer; column-count: unset;

    Common values ​​are presented on these pages: initial, inherit, revert, revert-layer, unset.

Animation of the column-count property.

The property column-count can be animated progressively. But since the number of columns can only be an integer, the animation will necessarily be jerky.

Latius iam disseminata licentia onero­sus bonis omnibus Caesar nul­lum post haec adhi­bens modum orientis latera cuncta vexabat nec hono­ra­tis parcens nec urbium prima­tibus nec plebeiis. Latius iam disseminata licentia onerosus bonis omnibus Caesar nullum post haec adhi­bens modum orientis latera cuncta vexabat nec honoratis parcens nec urbium primatibus nec plebeiis.

Manipulating the column-count property programmatically.

Change the number of columns in Javascript.

JavaScript accepts at least two syntaxes for modifying the value of a property. The first, with the name of the property written in kebab-case (a dash to separate words), and the second with camel-case notation (an uppercase letter to separate words).

Javascript
let el = document.getElementById('id'); el.style['column-count'] = '2'; // or let el = document.getElementById('id'); el.style.columnCount = '2';

Read the number of columns in Javascript.

The code example below retrieves the value of column-count if it has been assigned in the HTML code, through the style attribute of the element. Values set via a CSS selector are not taken into account.

Javascript
let el = document.getElementById('id'); let value = el.style['column-count']; // or let el = document.getElementById('id'); let value = el.style.columnCount;

Read the computed value of column-count in Javascript.

The calculated value is either a value directly assigned to the element via a CSS selector or the style attribute, or it is an inherited value, or it is the initial value of the property (auto in the case of column-count).

Javascript
let el = document.getElementById('id'); let value = window.getComputedStyle(el).getPropertyValue('column-count');

Change the number of columns with JQuery.

JQuery also accepts two formats for the property name: in kebab-case or in camel-case.

JQuery

$('#id').css('column-count', '2');
// or
$('#id').css('columnCount', '2');

Read the computed value of the property column-count with JQuery.

JQuery
let value = $('#id').css('column-count');

Other code examples.

If these codes are not enough for you, see other examples on the page Javascript and CSS.

Test it yourself.

The buttons below apply the entered value to the property column-count and then display either the value as it was applied or the calculated value.

Simulator.

column-count :
CSS is a purely declarative programming language. In other words, it does not have the usual algorithmic structures such as loops. Nevertheless, the notion of testing, classically translated by the if statement in traditional languages, begins to appear in CSS through directives like @media or @supports. Variables also make their appearance in CSS under the name of custom properties.

Browsers compatibility with column-count.

The compatibility seems poor for multi-column layouts, but this is due to the break properties break-after, etc., which are not well recognized.

Column 1
Support for column layouts, including handling column breaks.
Column 2
Support for the column-count property allowing the text to be arranged in multiple columns.

Notes:

(1) Does not support the values avoid (in the column context), avoid-column, and avoid-page for the properties break-after, break-before, and break-inside.

(2) Does not support the properties break-after, break-before, and break-inside.

1
Multiple column
layout
2
column-count
property
Estimated overall support.
18%
96%

Browsers on computers :

Mobile browsers :

Outdated or marginal browsers :

Internet Explorer

Baidu Browser

QQ Browser

Opéra Mobile

Firefox

Chrome

Safari

Edge

Opéra

Chrome pour Androïd

Safari sur IOS

Samsung Internet

UC Browser pour Androïd

Androïd Brower

Firefox pour Androïd

KaiOS Browser

Opéra mini

Historic of the column-count property.

  • CSS Multi-column Layout Module Level 1

    This specification describes multi-column layout. It is enough to set the number of columns on the container, and the content will be arranged across the specified number of columns. Of course, other properties allow finer control over multi-column containers.
    This specification also defines properties concerning the space between columns and any possible dividing line.

    Regarding column-count. Introduced multi-column layouts, and related properties, such as column-count.
    WD
    June 23, 1999
    Working Draft.
    CR
    December 17, 2009
    Candidate Recommendation.
    PR
    REC
  • CSS Multi-column Layout Module Level 2

    Few new features on level 2 of this specification. Simply note a pseudo-element ::column which allows targeting the columns themselves (all columns at once). It accepts few properties.

    Regarding column-count. No modification of the property column-count except that values 0 are now prohibited.
    WD
    December 19, 2024
    Working Draft.
    CR
    PR
    REC

Other properties related to multi-columns.

Multi-column layouts are described in the specification CSS Multi-column Layout Module. The property column-count is explained in this module. You will also find the reference for the terms below:

Properties:

Column-count
Sets the number of columns, in a multi-column layout.
column-fill
Langue française
Manages the distribution of content across columns.
column-height
Langue française
Sets the height of the columns in the case of a multi-column layout. This height can be less than the height of the container, resulting in a kind of table.
column-rule
Langue française
Shorthand property that defines all parameters of the separator trait between columns.
column-rule-color
Langue française
Defines the color of the column-separating rules in the context of a multi-column layout, a grid container, or a flex container.
column-rule-style
Langue française
Choose the type of line for separating columns, in the context of a multi-column layout, a flex container, or a grid container.
column-rule-width
Langue française
Defines the thickness of the separating line between columns, in the context of a multi-column layout, a flex container, or a grid container.
column-span
Langue française
Manages overlapping content across multiple columns.
column-width
Sets the width of the columns.
columns
Defines the characteristics of a multi-column layout.