CSS Multiple Columns, also known as CSS Multi-Column Layout, is a technique that allows text or content to be split into two or more columns, similar to a newspaper or magazine layout. This layout improves readability for long blocks of text and provides a professional and organized appearance for articles, blogs, or content-heavy websites.
The multi-column layout is controlled using CSS properties like column-count, column-width, column-gap, and column-rule. These properties allow you to define the number of columns, their widths, spacing between them, and even add vertical rules between columns.
The simplest way to create multiple columns is by using column-count:
.container {
column-count: 3;
column-gap: 20px;
}
In this example:
Instead of specifying the number of columns, you can define the desired width for each column using column-width. The browser will automatically adjust the number of columns based on the available space.
.container {
column-width: 200px;
column-gap: 30px;
}
You can create vertical dividing lines between columns using column-rule:
.container {
column-count: 3;
column-gap: 20px;
column-rule: 2px solid #ccc;
}
For more control, you can combine multiple properties to achieve a refined multi-column layout:
.container {
column-count: 4;
column-width: 150px;
column-gap: 25px;
column-rule: 1px dashed #888;
}
Multi-column layouts can adapt to different screen sizes using media queries:
.container {
column-count: 3;
column-gap: 20px;
}
@media (max-width: 800px) {
.container {
column-count: 2;
}
}
@media (max-width: 500px) {
.container {
column-count: 1;
}
}
CSS Multiple Columns are widely supported in modern browsers including Chrome, Firefox, Edge, Safari, and Opera. Vendor prefixes like -webkit- or -moz- may be needed for older browser versions to ensure full compatibility.
CSS Multiple Columns is a powerful tool for creating organized, readable, and visually appealing layouts for text-heavy content. Using a CSS Multiple Columns Generator allows designers and developers to experiment with the number of columns, widths, gaps, and rules visually, making it easier to achieve professional layouts quickly without manually calculating dimensions or spacing.