treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Almanac

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
View Comments

Comments

  1. tarasj
    Permalink to comment#

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

Leave a Comment

Use markdown or basic HTML and be nice.