The ideal number of columns to divide the selected element.
Note: Suppose you also set column-width to a non-auto value.
In that case, browsers will read column-count’s integer value as
“maximum number of columns.”
You can use the CSS columns property as a shorthand for column-count. In other words, instead of:
You can alternatively use the columns property to shorten your code like so:
What Is a CSS column-width Property?
column-width tells browsers to divide the selected block element’s content into as many columns as the specified width can fill.
CSS column-width property’s value
Below are some of the values a column-width property accepts:
Value
Description
auto
Use other CSS properties, such as column-count, to determine the
width of columns.
Note:auto is column-width’s default value.
Positive integer
The ideal width of columns to divide the selected element.
Note: The columns may become wider than the specified width
because browsers will distribute the container’s extra space between
the columns. Therefore, it’s best to consider the integer value as
“minimum column width.”
You can use the CSS columns property as a shorthand for column-width. In other words, instead of:
You can alternatively use the columns property to shorten your code like so:
Defining Both the column-count and column-width Properties
Suppose you defined both the column-count and column-width properties on a multi-column container. In that case, browsers will read column-count as the maximum number of columns to divide the container’s content.
The snippet above read the column-count declaration as a hint to the maximum number of columns it can divide the <article>.
You can use the CSS columns property as a shorthand for column-count and column-width. In other words, instead of:
You can alternatively use the columns property to shorten your code like so:
How to Style CSS Multi-Columns
There is currently no way to style the column boxes that make up a multi-column layout.
We cannot style column boxes because they are anonymous, and we currently have no way to target anonymous items. Therefore, you cannot specify a column box’s background color, size, or border style.