Grow your CSS skills. Land your dream job.

column-count

Last updated on:

The column-count property in CSS controls how many vertical columns text in a particular element will be broken into. For instance:

p.intro-text {
   column-count: 3;
}

It is meant to be paired with column-gap, where you can specify how wide the gutter is between the text. You'll also need to prefix the properties to get the best browser support.

p.intro-text {
  -webkit-column-count: 3;
  -webkit-column-gap:   20px;  
  -moz-column-count:    3;
  -moz-column-gap:      20px;
  column-count:         3;
  column-gap:           20px;
}

Of which you would apply to a block of text like so:

<p class="intro-text">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra.</p>

Example

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus

Note that the height of each column is auto-balanced, as per the spec.

All Related Properties

.three-col {
  column-count: 3;
  column-gap: 20px;
  column-rule-color: #ccc;
  column-rule-style:solid;
  column-rule-width: 1px;
}

You can also set the column-width (with prefixes) but it generally makes more sense to let it auto calculate that.

The rule ("rule", as in, a line) will split the gap down the middle. You can use the same values as you would a border.

Take care not to have your text blocks be so enormously tall that they are taller than a (fairly small) browser window, otherwise it's the same problem as text being wider than the browser window (scrolling back and forth to read = sucks). Also consider text-align: justify;

JavaScript Fallback

Is presented in this A List Apart article.

More Information

Browser Support

Chrome Safari Firefox Opera IE Android iOS
Any 3+ 1.5+ 11.1+ 10+ TBD TBD

Comments

  1. tarasj
    Permalink to comment#

    where can i make a best use of it or how websites make use of this property
    thanks

  2. Very interesting stuff! I’ve recently been wanting to use this in a website I’ve made where I was asked to look at good quality magazines for design style (adapting as necessary of course).

    Chris, can you please give an example of this being used in action (on a site or web app) to good effect?

  3. Permalink to comment#

    I’m testing this page in Opera v12.16, build 1860 and the example text appears in a single column. Is perhaps something missing?

    Luis

  4. Luis: You may look at my website, where I use some of these functions like column in combination with soft-hyphens and text blocks. You can find them all at wpö.de. But be »warned« – it’s all German and at very high speaking level. Try to find out, what you get with »Silbentrennung einschalten« in the navigation bar at the left side of each page. Additionally, there is a self-written function in JavaScript (upto today programming is in progress), that formats the text content around floating blocks like pictures or tables. The normal CSS attibutes like float belonging to blocks and with affection to text in parent’s elements can’t work here. So I made my own work-around. Try and find out! Have fun! (Sorry for my bumpy English!)

  5. Permalink to comment#

    column-count is a very useful property and it has helped me in a a lotta ways even with image grids.

  6. ura soul

    opera 12.16 – i am seeing that a 2 column layout renders with 1 empty column..

    and with chrome/chromium there is a known bug with the balancing algorithm for the columns that results in large empty spaces at the bottom of the column areas.
    so overall, too buggy to use.. except, i am already using it! doh!

Leave a Comment

Current day month ye@r *

*May or may not contain any actual "CSS" or "Tricks".