column-count 70482h
The column-count property allows you to lay an element’s content in multiple columns by specifying a number of columns. 1b4w6u
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 4j1l4a
- 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 4w6m73
- auto
-
Means that the number of columns will be determined by other properties (e.g.,
column-width
, if it has value other thanauto
). - <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
andcolumn-count
have non-auto values, the integer value describes the maximum number of columns.
Examples 3y6d6i
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 176n59
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 PlaygroundBrowser s162l
CSS3 Multiple column layout 1x2y3u
Method of flowing information in multiple columns
W3C Candidate Recommendation
ed from the following versions:
Desktop 1i5h4c
- 50
- 52
- 10
- 11
- 10
Mobile / Tablet 1u2r2g
- 10
- 66
- all
- 66
- 60