Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Grid

The grid-auto-columns property

Reference for the CSS grid-auto-columns property: size the implicit columns a grid creates automatically, with track values, minmax(), examples and notes.

The grid-auto-columns property sizes the implicit columns of a grid, which are the columns the browser adds when an item is placed beyond the columns declared by grid-template-columns. It matters most with grid-auto-flow: column, where every new item gets a new column.

If you list several sizes, they repeat in order for as many implicit columns as are needed.

CSS
.strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 120px;
}

Try it

Implicit columns of fixed width

Syntax

CSS
grid-auto-columns: <track-size>+;

/* <track-size> */
<length-percentage> | <flex> | min-content | max-content | auto
  | minmax( <inflexible-breadth>, <track-breadth> )
  | fit-content( <length-percentage> )
  • Initial value: auto
  • Applies to: grid containers
  • Inherited: no
  • Animatable: yes, between lists with the same number of compatible values (lengths and percentages); other values change abruptly
  • Computed value: the list, with lengths made absolute

Values

Value Description
auto Sized by content, and stretches to take up free space if justify-content is normal or stretch.
<length> / <percentage> A fixed width or a share of the grid container's width.
<flex> (1fr) A share of the remaining space.
min-content / max-content The narrowest or widest the content can be.
minmax(min, max) A range, such as minmax(100px, 1fr).
fit-content(limit) Content width, but never wider than the limit.
Several values Used in sequence and repeated for further implicit columns.

Usage notes

  • Only implicit columns. It never changes columns defined in grid-template-columns.
  • Horizontal scrollers. grid-auto-flow: column plus grid-auto-columns: minmax(200px, 1fr) and overflow-x: auto gives a card carousel without extra markup.
  • repeat() isn't allowed here except as the list itself; write the sizes out.
  • auto is not a width of zero. An empty implicit column still takes its gap.
  • Implicit columns appear by placement too. An item with grid-column: 6 in a 3-column grid creates columns 4 to 6 using this property.

Browser support

Supported in all current browsers.