column-fill

Avatar of Katy DeCorah
Katy DeCorah on (Updated on )

DigitalOcean provides cloud products for every stage of your journey. Get started with $200 in free credit!

When you add height to a multi-column element, you can control how the content fills the columns. The content can be balanced or filled sequentially.

ul {
  height: 300px;
  -webkit-columns: 3;
     -moz-columns: 3;
          columns: 3;
  -moz-column-fill: balance;
       column-fill: balance;
}

This property is only available in Firefox. Firefox will automatically balance content in a height-constrained multi-column layout. The other browsers will always fill columns sequentially when given a height constraint.

To make Firefox behave like the other browsers, that is to fill columns sequentially, you can set column-fill: auto.

Values

column-fill accepts the keyword values balance and auto.

balance will fill each column with about the same amount of content, but will not allow the columns to grow taller than the height. You might find that the columns will come up shorter than the height as the browser distributes the content evenly horizontally.

auto will fill each column until it reaches the height and do this until it runs out of content. Given the content, this value will not necessarily fill all the columns nor fill them evenly.

It’s kind of like pouring juice into glasses. You can pour an equal amount of juice into each glass and find that you don’t fill each glass to the top (balance). Alternatively, you can fill a glass to the top until it’s full and repeat this until no juice is left. As a result, the remaining glasses may have less or no juice (auto).

See the Pen column-fill example [CSS-Tricks] by CSS-Tricks (@css-tricks) on CodePen.

Related Properties

Additional Resources

Browser Support

The column-fill keyword values specifically work in Firefox. They didn’t work in August 2014 when this Almanac entry was originally written, but does when tested again in August 2015 (Chrome 44). During that testing, it seems that changing the value dynamically wouldn’t take, you had to force a relayout.

Browser support for multi-column layout in general:

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

Don’t forget your prefixes!