CSS Grid Auto Rows: Master Implicit Row Track Sizing for Dynamic Layouts

June 19, 2025

CSS Grid revolutionized web layout design, offering unprecedented control over both rows and columns. While you explicitly define grid tracks using grid-template-rows, CSS Grid automatically creates additional rows when content exceeds your defined structure. The grid-auto-rows property gives you precise control over these automatically generated implicit rows.

Understanding CSS Grid Auto Rows

The grid-auto-rows property defines the size of implicitly created row tracks in a CSS Grid container. When grid items are placed outside the explicit grid structure or when content naturally flows beyond defined rows, CSS Grid automatically generates new rows. This property determines how tall these auto-generated rows should be.

Key Concept: Explicit rows are those defined with grid-template-rows, while implicit rows are automatically created by the browser when needed.

CSS Grid Auto Rows Syntax

The basic syntax for grid-auto-rows is straightforward:

.grid-container {
  display: grid;
  grid-auto-rows: <track-size>;
}

Available Values

The grid-auto-rows property accepts several types of values:

  • Length values: 100px, 2rem, 50vh
  • Percentage values: 25%, 50%
  • Flexible values: 1fr, 2fr
  • Content-based values: auto, min-content, max-content
  • Functions: minmax(), fit-content()
  • Multiple values: Space-separated list for different sizing patterns

Basic CSS Grid Auto Rows Examples

Fixed Height Auto Rows

Setting a fixed height ensures all implicit rows have the same consistent size:

.grid-fixed {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 80px; /* Only one explicit row */
  grid-auto-rows: 120px; /* All implicit rows will be 120px tall */
  gap: 10px;
  padding: 20px;
  background: #f0f4f8;
}

.grid-item {
  background: #4299e1;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6

In this example, the first row (explicit) is 80px tall, while the second row (implicit) automatically becomes 120px tall due to grid-auto-rows.

Auto-Sizing Based on Content

Using auto value makes rows size themselves based on their content:

.grid-auto {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: auto;
  gap: 15px;
  padding: 20px;
  background: #f7fafc;
}
Short content
This is much longer content that will make this grid item taller than the others because it contains more text and needs more space to display properly.
Medium length content here
Brief text

Advanced Grid Auto Rows Techniques

Using Fractional Units (fr)

Fractional units create flexible rows that share available space proportionally:

.grid-fr {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 60px;
  grid-auto-rows: 2fr; /* Implicit rows take 2 fractional units */
  height: 400px;
  gap: 10px;
  padding: 20px;
  background: #edf2f7;
}
Explicit Row
60px tall
Fixed height
Implicit Row
2fr flexible
Shares space

MinMax Function for Flexible Boundaries

The minmax() function provides both minimum and maximum constraints for implicit rows:

.grid-minmax {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(100px, auto);
  gap: 15px;
  padding: 20px;
  background: #f0fff4;
}
Minimum 100px height
This cell has significantly more content, so it will expand beyond the 100px minimum to accommodate all the text while maintaining readability and proper spacing throughout the entire grid item area.
Another short item
Normal content

Multiple Track Sizes Pattern

You can define multiple sizes that repeat in a pattern for implicit rows:

.grid-pattern {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 80px 120px 100px; /* Pattern repeats */
  gap: 10px;
  padding: 20px;
  background: #fffaf0;
}
80px
80px
80px
80px
120px
120px
120px
120px
100px
100px
100px
100px

The pattern (80px, 120px, 100px) repeats for each set of implicit rows, creating a rhythmic visual design.

Interactive Example: Dynamic Grid Auto Rows

Experiment with different grid-auto-rows values using this interactive example:


Explicit Row
60px tall
Fixed height
Auto Row 1
Changes with selection
Dynamic sizing
Auto Row 2
Pattern continues
As needed
Current CSS: grid-auto-rows: auto;

Real-World Use Cases

Card Layouts with Variable Content

Perfect for blog post previews, product cards, or any content where text length varies:

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  grid-auto-rows: minmax(200px, auto);
  gap: 20px;
}

Short Article Title

Brief description of the article content.

Much Longer Article Title That Spans Multiple Lines

This article has a much longer description that provides more detailed information about the content, explaining various concepts and providing additional context that makes the card taller than others in the grid layout.

Another Article

Medium-length description that fits comfortably in the card space.

Photo Gallery with Mixed Orientations

When displaying images of different aspect ratios, grid-auto-rows helps maintain visual harmony:

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  grid-auto-rows: 200px;
  gap: 15px;
}
Photo 1
Photo 2
Photo 3
Photo 4
Photo 5

Browser Support and Considerations

CSS Grid and grid-auto-rows enjoy excellent browser support across all modern browsers. The property works consistently in:

  • Chrome: Full support since version 57
  • Firefox: Full support since version 52
  • Safari: Full support since version 10.1
  • Edge: Full support since version 16
Legacy Support: For older browsers, consider using flexbox or float-based layouts as fallbacks, though CSS Grid adoption is now widespread enough that fallbacks are rarely necessary.

Performance and Best Practices

Optimization Tips

Follow these best practices when using grid-auto-rows:

Use appropriate units: Choose units that make sense for your content. Use auto for content-driven layouts, fixed units for consistent designs, and fractional units for flexible spacing.

Consider content flow: Design your grid with implicit row creation in mind. Plan for how content will flow when it exceeds your explicit grid structure.

Test with variable content: Always test your grid layouts with different amounts of content to ensure grid-auto-rows behaves as expected.

Combine with media queries: Adjust grid-auto-rows values for different screen sizes to maintain optimal layouts across devices.

@media (max-width: 768px) {
  .responsive-grid {
    grid-auto-rows: auto; /* Content-based on mobile */
  }
}

@media (min-width: 769px) {
  .responsive-grid {
    grid-auto-rows: 200px; /* Fixed height on desktop */
  }
}

Common Mistakes to Avoid

Forgetting about implicit rows: Not considering how content will behave when it exceeds your explicit grid can lead to unexpected layouts.

Using inappropriate values: Setting fixed heights when content varies significantly can cause overflow or wasted space.

Ignoring responsive behavior: Not adjusting grid-auto-rows for different screen sizes can create poor mobile experiences.

Overcomplicating patterns: While multiple values create interesting patterns, overly complex sequences can be hard to maintain and debug.

Advanced Integration Techniques

Combining with Grid Auto Flow

Use grid-auto-rows together with grid-auto-flow for complete control over implicit grid behavior:

<pre style=”background: #2d3748; color: #e2e8f0; padding: 20px; border-radius: 8px; overflow