![]() |
VOOZH | about |
The CSS columns property is used to control both the number of columns and the width of those columns in a layout. It’s a shorthand property that allows you to set multiple values at once, such as the number of columns and their width.
This makes it easier to create multi-column layouts without manually defining each column’s style.
Currently Active Property:
columns: 3;
columns: column-width columns-count | auto | initial | inherit;Here are the Property Values for the CSS columns Property:
| Property Value | Description |
|---|---|
auto | Sets the column-width and column-count to their default values defined by the browser. |
integer | Specifies the column-width and column-count using integer values. |
initial | Initializes the column-width and column-count values to their default initial values. |
inherit | Inherits the column-width and column-count values from its parent element. |
Here are the Examples of the columns Property:
columns Property with Automatic Column DistributionIn this example, the columns property is used to split the content into multiple columns, where the number of columns and their width are automatically determined by the browser. The content inside the div with the class GFG will be laid out in as many columns as the browser can fit, based on the available space and content.
Output:
Note: If any of the values among the column-width and column-count are not specified, then the browser assumes their value as auto by default.
integer: This is used to specify the column-width and the column-count using integer values.
columns Property for Multi-Column LayoutIn this example, we use the CSS columns property to create a multi-column layout. The text content inside the div with the class GFG is split into five columns, each with a minimum width of 60px. The columns property works across browsers, with specific vendor prefixes for better compatibility.
Output:
The browsers supported by columns Property are listed below:
Note: Ensure to test on older browser versions for compatibility, as some may require vendor prefixes (
-webkit,-moz) for full functionality.