CSS Reference Property

columns 1z2645

The columns property allows you to lay an element’s content in multiple columns. 5b1j1z

It is a shorthand property for setting the longhand properties: column-count.

Using columns, you can specify the number and width of columns that you want the element’s content to be laid into. You can specify values for both the column-count properties, or for only one of them. If you leave one of them out, it is set to its initial (default) value.

Setting both column-count and column-width may not always make 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.

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.

If the width and count of columns do not fit into the width of the element, the browser will make necessary adjustments and may reduce the column count to fit the specified column widths into the element. If the column count is reduced to 1, and the column width is still wider than the element’s width, the width is also narrowed down to fit the element. If the width of the columns is small so that the entire specified number can fit and more space remains available, the browser will stretch the columns’ width in the available space.

Official Syntax 55184y

  • Syntax:

    columns: <"column-width"> ||  <"column-count">
  • Initial: auto auto; which is the concatenation of the initial values of the two longhand properties.
  • Applies To: non-replaced block-level elements (except table elements), table cells, and inline-block elements
  • Animatable: both of the longhand properties is animatable.

Values 584j31

<‘column-width’> || <‘column-count’>
Values for the <integer> value. An omitted value is set to its initial value.

See the column-count entries for more information about the possible values for each.

Examples 3e5p5z

The following example lays the contents of the .mag element in two columns, each having a width of ’12em’.

.mag {
  columns: 12em 2;
}

            

The following are all possible columns values:

columns: 3; /* 3 columns, their widths are "auto" which means that the browser will determine the widths based on the available space */
columns: 300px 3; /* 3 columns, each 300px wide */
columns: 25%; /* columns each 25% of the container width. Column count is determined by the browser based on the available space */
            

Live Demo 2x4j2k

Play with the values of the columns property in the following demo to see how the layout changes. Try using different column counts and widths that are wider than the element itself to see how the browser handles these scenarios.

View this demo on the Codrops Playground

Browser k5t66

CSS3 Multiple column layout 5k44y

Method of flowing information in multiple columns

W3C Candidate Recommendation

ed from the following versions:

Desktop 3n671n

  • 50
  • 52
  • 10
  • 11
  • 10

Mobile / Tablet 4q224p

  • 10
  • 66
  • all
  • 66
  • 60

* denotes prefix required.

  • ed:
  • Yes
  • No
  • Partially
  • Polyfill

Stats from caniuse.com

Further Reading 4g1p1d

Written by

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

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