Multi-column text using CSS3

CSS3 offers a new way to arrange text content using the Multi-column CSS3 module. This CSS3 feature will help you fit your text into columns without extra markup like div floats or extra table markup.

Multi column text using CSS3

Short browser history and support

The draft was published a decade ago – in 2001, but only in April 2005, with the release of the Firefox 1.5 beta (based on Gecko 1.8), parts of the CSS3 Multi-Column module were supported.

Multi-column module is currently supported only in Mozilla and Webkit browsers (Safari and Chrome), this means that there’s no support for browsers like IE and Opera. But that should be just OK as long we are aware and understand the progressive enhancement.

W3C says that:

…style sheets can declare that the content of an element is to be laid out in multiple columns

OK, so how to use it?

As you read above, being supported only by Mozilla and Webkit-based browsers, means that vendor prefixes like -moz- and -webkit- must be used.

The CSS3 module properties

  • column-count – the desired number of columns for the element.
  • column-width – the width of each column.
  • column-gap – the padding between columns.
  • column-rule – to specify a border between columns as a divider.

Enough with the theory, let’s see some action!

There are two ways to define columns:

  • column-count – how many columns do you need
  • column-width – how wide should each column be

Column count

#multi-column1 {
  -moz-column-count: 3;
  -webkit-column-count: 3;
  -moz-column-gap: 20px;
  -webkit-column-gap: 20px;
  text-align: justify;
}

Column width

#multi-column2
{
  -moz-column-width: 200px;
  -webkit-column-width: 200px;
  -moz-column-gap: 30px;
  -webkit-column-gap: 30px;
  text-align: justify;
}

Alternatively, you may use the shorthand columns property.

Column rules

Either you choose column-count or column-width to define you columns, to add a border between them append the following CSS declarations:

  -moz-column-rule: 2px solid #9c9c9c;
  -webkit-column-rule: 2px solid #9c9c9c;

Conclusion

These are the most interesting Multi-column CSS3 module properties but if you want to find out more, please visit the W3C specifications for other details.

Below you have an example that shows you how to arrange a paragraph into columns, enjoy the demo and please let me know your thoughts about it!

View Demo

If you enjoyed this article, you might also like:

Written by Catalin Rosu

Catalin Rosu, a.k.a Red, is a passionate web designer and developer who loves to be creative and enjoys CSS techniques. Stay tuned for latest updates, subscribe to RSS and follow him on Twitter.

13 Responses to “Multi-column text using CSS3”

  1. SiMBA says:

    awesome dude . thanks

  2. sawal says:

    this one is pretty nice

  3. Red says:

    Thanks for your comments!

  4. CSS Blog says:

    Hi Catalin, if you want some more about Multi-column Layout Module don’t miss the CSS3 tutorial CSS3 Multi-column Layout!

  5. Opera is working on implementing the multiple-column module, the properties of which are very likely to be prefixed with “-o-”. You might want to include these in your example CSS already.

    • Red says:

      Thanks for your comment and suggestion Peter.

      As you notice, no future proof CSS code was added for this tutorial.

      If you wish to prepare your code for further implementation, beside -o- you may add -ms- (for IE9) and also the non-prefixed properties.

      Until then, I’ll wait to see it implemented in Opera, as version 11 was released without any support for Multi-column module.

  6. vasiauvi says:

    Interesant!
    I started to learn some things in CSS(3) and this tutorial will help me!
    Thanks!

  7. ahkeno says:

    nice post! love CSS3 and your sharing

  8. What browser you suggest ti work with css3. I use to be Opera, but don’t work correctly with somes css, its the same to IE6, IE7 and IE8

    With CSS3 that problen are solved?

    • Red says:

      The multi-column module is currently supported only in Mozilla and Webkit browsers (Safari and Chrome).

      So, currently, Opera doesn’t support this module.

  9. Mark says:

    Organization means a lot on a web page. Thanks for the demo.

Leave a Reply