VOOZH about

URL: https://www.geeksforgeeks.org/css/css-grid-auto-flow-property/

⇱ CSS grid-auto-flow Property - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

CSS grid-auto-flow Property

Last Updated : 11 Jul, 2025

The grid-auto-flow property Specifies exactly how auto-placed items get flowed into the grid.

Syntax

grid-auto-flow: row | column | row dense | column dense;

Here we explore one by one

Using grid-auto-flow: row

The grid-auto-flow: row property in CSS places items by filling each row sequentially, adding new rows as needed.

Example: In this example define a 2x4 grid with specified row and column sizes. Items are placed in order across rows due to grid-auto-flow: row, with specific styling for each grid cell.

Output:

👁 Image

Using grid-auto-flow: column

The grid-auto-flow: column property places items by filling each column sequentially, adding new columns as needed.

Example:  This example we creates a 2x4 grid with specified row and column sizes. Items are placed sequentially down columns due to grid-auto-flow: column, with specific styling for each grid cell.

Output:

👁 Image

Using grid-auto-flow: column dense

The grid-auto-flow: column dense property places items in columns, using a dense algorithm to fill gaps efficiently

Example: In this example we defines a 2x4 grid with specified row and column sizes. Items flow into columns and use dense packing mode, filling in empty spaces due to grid-auto-flow: column dense.

Output:

👁 Image

Using grid-auto-flow: row dense

The grid-auto-flow: row dense property places items in rows, using a dense algorithm to fill gaps efficiently.

Example: In this example we creates a 2x4 grid with defined row and column sizes. Items flow into rows and use dense packing mode, filling in empty spaces due to grid-auto-flow: row dense.

Output:

👁 Image

Supported Browsers

The browser supported by CSS grid-auto-flow Property are listed below:

Comment
Article Tags:
Article Tags: