columns

Term side of the Card.
Topic: Columns & Tables
Unit title: columns
Categories: Property
Explanation side of the Card

Explanation: The shorthand property that combines `column-width` and `column-count` properties, enabling to define both the width and the number of columns in a multi-column layout in a single line. This makes it easier to control the layout's appearance.

Browser compatibility:
  • The chrome browser supports this feature starting from version 50.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 52.
  • The safari browser supports this feature starting from version 9.
Availability: 

Example

Wrongcss
.articles {
  column-count: 3;
}
Rightcss
.articles {
  columns: 16rem 3;
  column-gap: 2rem;
}

With a width and a count, the browser uses at most three columns and only as many as fit at about 16rem each.

Common mistakes

  • Three fixed columns become unreadably narrow on phones.
  • A card is cut in half and continues at the top of the next column.

Key points

  • The value combines a minimum width and a maximum count, like '16rem 3', so columns drop on small screens.
  • Items that must not split across columns have break-inside: avoid.
  • Card grids that read left to right use Grid, since columns fill top to bottom.

Interview questions

Can I use CSS columns for a masonry layout?

It looks similar, but items flow down each column first, so the reading order goes top to bottom instead of across rows.

What is the difference between columns and grid?

Columns flow one continuous content stream into columns. Grid places items in rows and columns you define.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy