CSS columns Property
The CSS columns property is a shorthand for the following properties:
column-count, which defines the maximum number of columns.column-width, which defines the minimum width of columns.
These two properties together create a multi-column layout that adapts to the container width, typically reducing the number of columns as space decreases.
The columns property is one of the CSS3 properties.
Setting both column-count and column-width does not always make sense, as it can restrict the flexibility and responsiveness of the layout.
INFO
If the width and count of columns do not fit into the width of the element, the browser will automatically reduce the column count to fit the specified column widths.
| Initial Value | auto auto |
|---|---|
| Applies to | Block containers except table wrapper boxes. |
| Inherited | No. |
| Animatable | Yes. Only column-width is animatable. |
| Version | CSS3 |
| DOM Syntax | object.style.columns = "100px 2"; |
Syntax
Syntax of CSS columns Property
columns: [ <'column-width'> || <'column-count'> ] | auto | initial | inherit;Example of the columns property:
Example of CSS columns Property with column-width and column-count properties
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
.example {
columns: 100px 3;
}
</style>
</head>
<body>
<h2>Columns property example</h2>
<div class="example">
Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</body>
</html>Result

In the next example the minimum width for each column is set to 50px, and the maximum number of columns to 5:
Example of the columns property with specified width and number of columns:
Example of CSS columns Property with column-width and column-count properties as a value
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
.example {
columns: 50px 5;
}
</style>
</head>
<body>
<h2>Columns property example</h2>
<div class="example">
Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</body>
</html>Values
| Value | Description |
|---|---|
auto | Both column-width and column-count are set to auto. This is the default. |
<length> | Sets the minimum width for columns. |
<integer> | Sets the maximum number of columns. |
initial | Sets the property to its default value. |
inherit | Inherits the property from its parent element. |
Practice
What are the properties used to create multi-column layouts in CSS?