CSS Reference Property

column-count 2to2m

The column-count property allows you to lay an element’s content in multiple columns by specifying a number of columns. 326r2y

Depending on the available space, the browser will determine the width of the columns, unless you specify an exact width using the column-width property.

Setting both column-count and column-width does not always make much sense, as it may restrict the flexibility and responsiveness of the layout, such as if you use absolute widths for the columns instead of percentage widths.

Specifying the number of columns is simple. For example, the following sets the number of columns to 3 on the page.

body {
    column-count: 3;
}
                

Laying content, like text and images, in multiple columns is usually done in print magazine layouts, and using this property, along with others, you can create a similar effect on the web.

Official Syntax 3xs5l

  • Syntax:

    column-count: <integer> | auto
  • Initial: auto
  • Applies To: non-replaced block-level elements (except table elements), table cells, and inline-block elements
  • Animatable: yes, as a integer

Values u704t

auto
Means that the number of columns will be determined by other properties (e.g., column-width, if it has value other than auto).
<integer>
Describes the optimal number of columns into which the content of the element will be flowed. Values must be greater than 0. If both column-width and column-count have non-auto values, the integer value describes the maximum number of columns.

Examples 2h2053

The following example specifies the number of columns on an element with a class name mag. Then, using media queries, the number of columns is changed on small screens.

.mag {
  column-count: 2;
}

@media screen and (max-width: 30em) {
    .mag {
        column-count: 1;
    }
}
            

Live Demo 6b4m17

Play with the values of the column count to see how the text adjusts. Resize the screen to see how the width of the columns changes. Try using media queries to change the number of columns on different screen sizes.

View this demo on the Codrops Playground

Browser 572e63

CSS3 Multiple column layout 473p4a

Method of flowing information in multiple columns

W3C Candidate Recommendation

ed from the following versions:

Desktop ea5q

  • 50
  • 52
  • 10
  • 11
  • 10

Mobile / Tablet 6s2f12

  • 10
  • 66
  • all
  • 66
  • 60

* denotes prefix required.

  • ed:
  • Yes
  • No
  • Partially
  • Polyfill

Stats from caniuse.com

Further Reading 4s104w

Written by

Last updated June 11, 2020 at 10:24 pm by Mary Lou

Do you have a suggestion, question or want to contribute? Submit an issue.