SHARE
Facebook X Pinterest WhatsApp

Using CSS3 to Create Multi-Column Layouts in Your Web Pages

Written By
thumbnail
Vipul Patel
Vipul Patel
Jun 23, 2014

To support the “newspaper” type layout in your web application, the W3C offers the multi-column layout in the CSS3 specification. This multi-column layout enables web developers to fit a given text in one or more columns.

Use of multi-column layout supports flexibility since content can easily flow from one column to the other, and the number of columns can vary depending on the view port.

 

Properties associated with multi-column layout

  • Column-width – This specifies the width of the column.
  • Column-count- This specifies the number of columns of a multicol element.
  • Columns – This is a short cut to specify both column-width and column-count.
  • Column-gap – This specifies the gap between columns. It cannot be negative.
  • Column-rule-color – This property specifies the color of the column rule. It accepts any valid “color” value.
  • Column-rule-style – This property specifies the style of the rule between columns of an element.
  • Column-rule-width – This property specifies the width of the rule between columns. It cannot be negative.
  • Column-rule – This is a short cut to specify column-rule-color, column-rule-style and column-rule-width properties.
  • Break-before – This property specifies page/column break behavior before the generated box. The valid values are “auto”, always”, “avoid”, left” “right”, “page”, “column”, “avoid-page”, and “avoid-column”.

10.  

Break-after – This property specifies page/column break behavior after the generated box. The valid values are “auto”, “always”, “avoid”, left” “right”, “page”, “column”, “avoid-page”, and “avoid-column”.

Break-inside – This property specifies page/column break behavior inside the generated box. The valid values are “auto”, “avoid”, “avoid-page”, and “avoid-column”.

12.   Column-span – This property specifies how many columns an element spans across.  The valid values are “none” and “all”.

13.   Column-fill – This property specifies how to fill columns. Valid values are “auto” and “balance.

 

For the break behavior mentioned in bullet points #9, #10 and #11, here is the definition of what the values represent.

Value

Meaning

Auto

Column break is neither force not prohibited.

Always

It forces a page break before the generated box.

Avoid

It prevents a page break before the generated box.

Left

It forces page breaks before the generated box to support generating the next page as a left page

Right

It forces page breaks before the generated box to support generating the next page as a right page

Page

It forces a page break before the generated box.

Column

It forces a column break before the generated box.

Avoid-page

It avoids a page break before the generated box.

Avoid-column

It avoids a column break before the generated box.

 

Per the CSS3 specification, multi-column layouts can be defined in various ways:

      Defining multi-column layout by specifying width

We can specify a multi-column layout by providing the “column-width”. E.g.

body {

     column-width: 10em

}

In the example above, we have specified that the column be at least 10em wide.

 

2.       Defining multi-column layout by specify number of columns

We can specify a multi-column layout by providing the number of columns to break the content into.

body {

     column-count: 3

}

 

3.       Defining “column-width” and “column-count” in one command “columns”.

body {

     columns: 3

}

We can see the many ways in which we can specify the multi-column layout.

Summary

In this article, we learned about how to use USS3 to create multi-column layouts in your web pages

 

About the author

Vipul Patel is a Program Manager currently working at Amazon Corporation. He has formerly worked at Microsoft in the Lync team and in the .NET team (in the Base Class libraries and the Debugging and Profiling team). He can be reached at vipul.patel@hotmail.com

 

Reference

http://www.w3.org/TR/css3-multicol/

 

Recommended for you...

Importing Custom Less Styles at Run-time in Angular
Rob Gravelle
Jun 14, 2022
Setting CSS Values from Less Variables in Angular
Rob Gravelle
Jun 4, 2022
Color Manipulation with JavaScript
Rob Gravelle
May 21, 2022
An Introduction to CSS-in-JS
Rob Gravelle
May 14, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.